/* =====================================================================
   Composizione Crisi – foglio di stile
   Palette del marchio: blu notte, petrolio, salvia.
   Solo grafica: le classi sono quelle usate da common.js, portal.js,
   conferma.js, liquidazione.js e studio/*.js.
   ===================================================================== */
:root {
  /* Marchio */
  --navy: #14213D;
  --navy-dark: #0B1528;
  --navy-2: #1C2D50;
  --petrol: #1F6F78;
  --petrol-dark: #175A62;
  --petrol-soft: #E1EEEF;
  --sage: #8FAE96;
  --sage-soft: #E9F0EA;
  --sage-line: #CBDACE;

  /* Testo e superfici */
  --ink: #14213D;
  --ink-2: #3A4863;
  --muted: #64708A;
  --line: #DFE5E5;
  --line-2: #ECF0EF;
  --field: #CBD4D6;
  --ground: #F3F5F4;
  --card: #FFFFFF;
  --soft: #E8EFEF;

  /* Stati */
  --ok: #2E6E4C;   --ok-bg: #E4F0E8;  --ok-fg: #24573B;
  --warn: #A86A12; --warn-bg: #FBF1DE; --warn-fg: #7E4F0A;
  --bad: #A23B3B;  --bad-bg: #F8E5E3;  --bad-fg: #8C2F2F;
  --danger: #A23B3B;
  --blue-bg: #E5ECF7;   --blue-fg: #24427E;
  --orange-bg: #FBF1DE; --orange-fg: #7E4F0A;
  --gray-bg: #EDF0F1;   --gray-fg: #4A5468;
  --teal-bg: #E1EEEF;   --teal-fg: #175A62;
  --purple-bg: #ECEAF5; --purple-fg: #4B3F86;
  --bg-2: #F5F7F6;

  /* Tipografia */
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
  --brandfont: "Avenir Next", "Avenir", "Century Gothic", -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Forme */
  --r-sm: 6px;
  --r: 9px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20, 33, 61, .05);
  --shadow-2: 0 1px 2px rgba(20, 33, 61, .04), 0 6px 20px -8px rgba(20, 33, 61, .12);
  --shadow-3: 0 2px 6px rgba(20, 33, 61, .06), 0 24px 60px -12px rgba(11, 21, 40, .35);
  --ring: 0 0 0 3px rgba(31, 111, 120, .22);

  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-size: 14px; line-height: 1.5;
  background: var(--ground);
  background-image: linear-gradient(180deg, #EEF2F1 0, var(--ground) 260px);
  background-repeat: no-repeat;
}
::selection { background: rgba(31, 111, 120, .18); }
a { color: var(--petrol-dark); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--navy); }
h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 31px; line-height: 1.15; letter-spacing: -.01em; color: var(--navy); }
h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 18.5px; line-height: 1.25; letter-spacing: -.005em; color: var(--navy); }
h3 { font-weight: 600; color: var(--navy); }
.card-body > h3:first-child, .card-body > .row-between > h3, .card-head h3 { font-family: var(--serif); font-size: 17px; letter-spacing: -.005em; }
.serif { font-family: var(--serif); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
b, strong { font-weight: 600; }
code, kbd { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ---------------------------------------------------------------
   Barra superiore (studio, area esterna, conferma)
   --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 0 28px; min-height: 62px;
  background: var(--navy);
  background-image: linear-gradient(100deg, var(--navy-dark) 0%, var(--navy) 45%, #17304A 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 6px 18px -10px rgba(11, 21, 40, .6);
}
.topbar::after { /* filo salvia sotto la barra */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--petrol) 0%, var(--sage) 55%, transparent 100%); opacity: .9;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.topbar .spacer { flex: 1; }
.avatar {
  height: 36px; padding: 0 14px 0 6px; border-radius: 18px; gap: 8px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14);
  color: #fff; display: flex; align-items: center; font-weight: 500; font-size: 13px; white-space: nowrap;
}
.avatar::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--petrol) url("/img/logo-cc-chiaro.svg") center / 16px auto no-repeat;
}
.avatar:empty { display: none; }

/* Residui della data room (non più usati nell'interfaccia) */
.brand-logos { display: flex; align-items: center; gap: 14px; }
.brand-logos img { height: 26px; width: auto; display: block; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

main { max-width: 1320px; margin: 0 auto; padding: 28px 28px 72px; display: flex; flex-direction: column; gap: 20px; }

/* ---------------------------------------------------------------
   Pulsanti e campi
   --------------------------------------------------------------- */
button, .btn {
  font: inherit; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 15px; border-radius: var(--r);
  border: 1px solid var(--field); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; font-weight: 500; line-height: 1.2;
  box-shadow: var(--shadow-1);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover { border-color: #A9B7BA; background: #FAFBFB; color: var(--navy); }
button:active, .btn:active { transform: translateY(.5px); }
button.primary, .btn.primary {
  background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600;
  background-image: linear-gradient(180deg, #1D2E52 0%, var(--navy) 100%);
  box-shadow: 0 1px 2px rgba(11, 21, 40, .25), inset 0 1px 0 rgba(255, 255, 255, .08);
}
button.primary:hover, .btn.primary:hover { background: var(--navy-dark); background-image: none; border-color: var(--navy-dark); color: #fff; }
button.primary-ghost, .btn.primary-ghost { border-color: var(--petrol); color: var(--petrol-dark); background: var(--petrol-soft); }
button.danger, .btn.danger { color: var(--bad); }
button.danger:hover { border-color: #D9A6A6; background: var(--bad-bg); color: var(--bad-fg); }
button.icon { min-height: 30px; padding: 0 9px; font-size: 12.5px; border-radius: var(--r-sm); box-shadow: none; }
.small-btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
button:disabled, .btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; box-shadow: none; }
button:disabled:hover { background: var(--card); border-color: var(--field); }
button.primary:disabled:hover { background: var(--navy); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }
button.primary:focus-visible { box-shadow: 0 0 0 3px rgba(143, 174, 150, .55); }
.install-btn { white-space: nowrap; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
label.field.wide { grid-column: 1 / -1; }
label.field .hint { font-size: 11.5px; font-weight: 400; color: var(--muted); }
label.field .miss { color: var(--bad); font-size: 11.5px; font-weight: 500; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }
input[type=text], input[type=email], input[type=date], input[type=search], input[type=number], input[type=password], input[type=tel], input[type=url], input:not([type]), select, textarea {
  font: inherit; font-size: 14px; min-height: 38px; padding: 0 12px;
  border: 1px solid var(--field); border-radius: var(--r); background: #fff; color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(20, 33, 61, .04);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #AEBBBE; }
input:focus, select:focus, textarea:focus { border-color: var(--petrol); }
input::placeholder, textarea::placeholder { color: #98A2B3; }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--bg-2); color: var(--ink-2); }
select {
  max-width: 100%; padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2364708A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select[multiple], select[size]:not([size="1"]) { padding: 6px 8px; background-image: none; }
textarea { padding: 10px 12px; resize: vertical; line-height: 1.5; }
input[type=checkbox], input[type=radio] { accent-color: var(--petrol); width: 16px; height: 16px; }
input[type=file] { font: inherit; font-size: 13px; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 500; margin-right: 12px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--field); border-radius: var(--r); background: #fff; color: var(--navy); box-shadow: var(--shadow-1);
}
input[type=file]::file-selector-button:hover { border-color: #A9B7BA; background: #FAFBFB; }
details > summary { cursor: pointer; font-weight: 600; color: var(--navy); }
details > summary::marker { color: var(--petrol); }
details[open] > summary { margin-bottom: 10px; }

/* ---------------------------------------------------------------
   Schede e griglie
   --------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  padding: 15px 22px; border-bottom: 1px solid var(--line-2);
}
.card-body { padding: 18px 22px; }
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; align-items: end; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1000px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.clamp { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------------------------------------------------------------
   Tabelle
   --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
  background: #F7F9F8; padding: 11px 16px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td { padding: 13px 16px; border-top: 1px solid var(--line-2); vertical-align: middle; }
thead + tbody tr:first-child td { border-top: 0; }
td.num { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
th.r, td.r { text-align: right; }
td.r { font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover td { background: #FAFBFB; }
tr.link { cursor: pointer; }
tr.link:hover td { background: #F3F7F7; }
tr.total td { background: var(--sage-soft); font-weight: 600; color: var(--navy); border-top: 1px solid var(--sage-line); }
td a { font-weight: 600; color: var(--navy); text-decoration: none; }
td a:hover { color: var(--petrol); text-decoration: underline; }

/* ---------------------------------------------------------------
   Pillole di stato ed etichette
   --------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 10px 0 8px;
  border-radius: 12px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  background: var(--gray-bg); color: var(--gray-fg);
  box-shadow: inset 0 0 0 1px rgba(20, 33, 61, .05);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; flex: none; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.prep, .pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.closed, .pill.idle { background: var(--gray-bg); color: var(--gray-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.info { background: var(--petrol-soft); color: var(--petrol-dark); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: 11.5px; font-weight: 600; }
.c-blue { background: var(--blue-bg); color: var(--blue-fg); }
.c-orange { background: var(--orange-bg); color: var(--orange-fg); }
.c-gray { background: var(--gray-bg); color: var(--gray-fg); }
.c-teal { background: var(--teal-bg); color: var(--teal-fg); }
.c-purple { background: var(--purple-bg); color: var(--purple-fg); }
.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--field); }
.dotc.ok { background: var(--ok); } .dotc.warn { background: #C98A1B; } .dotc.bad { background: var(--bad); } .dotc.info { background: var(--petrol); }

/* ---------------------------------------------------------------
   Navigazione: percorso e schede della pratica
   --------------------------------------------------------------- */
.crumbs { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: -6px; }
.crumbs a { text-decoration: none; color: var(--petrol-dark); font-weight: 500; }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-hidden] { color: #B3BCC9; }

.tabs {
  position: relative; display: flex; flex-wrap: nowrap; gap: 2px; padding: 5px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-1);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 8px 13px; border-radius: 8px; white-space: nowrap; scroll-snap-align: start;
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.tabs a:hover { background: var(--ground); color: var(--navy); }
.tabs a[aria-current=page] {
  background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 1px 2px rgba(11, 21, 40, .25), inset 0 -2px 0 var(--sage);
}
.tabs a:last-child { margin-right: 22px; }
@media (min-width: 1240px) {
  .tabs { flex-wrap: wrap; -webkit-mask-image: none; mask-image: none; }
  .tabs a:last-child { margin-right: 0; }
}

/* ---------------------------------------------------------------
   Data room: indice + documenti
   --------------------------------------------------------------- */
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > aside { flex: 1 1 260px; max-width: 340px; position: sticky; top: 82px; }
.split > section { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.tree { padding: 10px; display: flex; flex-direction: column; gap: 1px; }
.tree button.node {
  justify-content: flex-start; width: 100%; border: none; background: transparent; box-shadow: none;
  text-align: left; font-weight: 400; color: var(--ink-2); min-height: 34px; border-radius: 7px; position: relative;
}
.tree button.node svg { color: var(--petrol); flex: none; }
.tree button.node:hover { background: var(--ground); color: var(--navy); }
.tree button.node.active { background: var(--petrol-soft); color: var(--navy); font-weight: 600; }
.tree button.node.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--petrol); }
.tree .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--line-2); border-radius: 9px; padding: 0 7px; line-height: 18px; }
.drop {
  display: flex; align-items: center; gap: 14px; padding: 20px 22px;
  border: 1.5px dashed #B9C8C9; border-radius: var(--r-lg);
  background: linear-gradient(180deg, #FBFCFC, #F5F8F8); color: var(--ink-2);
  transition: border-color .15s ease, background-color .15s ease;
}
.drop svg { color: var(--petrol); flex: none; }
.drop.over { border-color: var(--petrol); background: var(--petrol-soft); }
.drop input { display: none; }
.drop a { color: var(--petrol-dark); font-weight: 600; }
@media (max-width: 820px) { .split > aside { position: static; max-width: none; } }

/* ---------------------------------------------------------------
   Messaggi
   --------------------------------------------------------------- */
.notice {
  padding: 13px 16px 13px 18px; border-radius: var(--r); position: relative;
  background: var(--petrol-soft); color: #173F47; border: 1px solid #C8DFE1;
  box-shadow: inset 3px 0 0 var(--petrol);
}
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: #EDD8B0; box-shadow: inset 3px 0 0 #C98A1B; }
.notice.err { background: var(--bad-bg); color: var(--bad-fg); border-color: #EBC5C1; box-shadow: inset 3px 0 0 var(--bad); }
.notice ul { line-height: 1.6; }
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60;
  max-width: calc(100% - 32px); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-3); border-left: 3px solid var(--sage);
  animation: toast-in .22s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------------------
   Finestre (dialog)
   --------------------------------------------------------------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; color: var(--ink);
  width: min(580px, calc(100% - 24px)); max-height: calc(100dvh - 32px);
  box-shadow: var(--shadow-3); overflow: auto;
}
dialog[open] { animation: dlg-in .2s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(11, 21, 40, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog form { padding: 0 24px 22px; display: flex; flex-direction: column; gap: 14px; }
dialog form > h2:first-child {
  margin: 0 -24px 2px; padding: 18px 24px 15px; font-size: 20px;
  border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, #F7F9F8, #fff);
}
dialog form > .actions:last-child { margin: 6px -24px -22px; padding: 14px 24px; border-top: 1px solid var(--line-2); background: #FAFBFB; border-radius: 0 0 16px 16px; }

/* ---------------------------------------------------------------
   Visualizzatore PDF
   --------------------------------------------------------------- */
.viewer { position: fixed; inset: 0; background: #1E2A40; z-index: 40; display: flex; flex-direction: column; }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 20px; background: var(--navy-dark); color: #fff; border-bottom: 2px solid var(--petrol); }
.viewer-bar button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.viewer-bar button:hover { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .4); }
.viewer-bar .title { font-weight: 600; }
.viewer-bar .sub { font-size: 12px; color: #B5C2D3; }
.viewer-pages { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; user-select: none; -webkit-user-select: none; }
.viewer-pages canvas { max-width: 100%; height: auto; background: #fff; box-shadow: 0 10px 36px rgba(0, 0, 0, .4); border-radius: 2px; }
.viewer-badge { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; background: rgba(143, 174, 150, .16); color: #DCE8DE; font-size: 12.5px; border: 1px solid rgba(143, 174, 150, .3); }

/* ---------------------------------------------------------------
   Pagina di accesso (area esterna)
   --------------------------------------------------------------- */
body.auth { background: var(--ground); }
body.auth .topbar { display: none; }
body.auth main { max-width: none; padding: 0; }
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(340px, 5fr) minmax(360px, 6fr); }
.auth-brand {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--navy-dark);
  background-image:
    radial-gradient(1200px 600px at -10% 110%, rgba(31, 111, 120, .55), transparent 60%),
    radial-gradient(700px 500px at 110% -10%, rgba(143, 174, 150, .22), transparent 60%),
    linear-gradient(160deg, #0B1528 0%, #14213D 55%, #17344A 100%);
  color: #E6ECF2; padding: 56px 56px 40px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-brand::before { /* i due archi del simbolo, in grande, come filigrana */
  content: ""; position: absolute; z-index: -1; right: -140px; bottom: -90px; width: 560px; height: 430px;
  background: url("/img/logo-cc-chiaro.svg") center / contain no-repeat; opacity: .06;
}
.auth-brand::after {
  content: ""; position: absolute; z-index: -1; left: 56px; right: 56px; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--petrol), var(--sage), transparent);
}
.auth-logos { display: flex; flex-direction: column; gap: 28px; align-items: flex-start; }
.auth-logos .plate {
  background: #fff; border-radius: 14px; padding: 0 26px; display: flex; align-items: center; justify-content: center;
  width: 330px; max-width: 100%; height: 108px; box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .5);
}
.auth-logos img.cc { width: 270px; max-width: 100%; height: auto; display: block; }
.auth-logos img.borrelli, .auth-logos img.legality { height: 50px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.auth-logos .and { font-family: var(--serif); font-style: italic; color: #A9B6C6; font-size: 15px; }
.auth-claim { font-family: var(--serif); font-weight: 500; font-size: 33px; line-height: 1.22; color: #fff; margin: 0; max-width: 17ch; letter-spacing: -.01em; }
.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: #C9D4DF; max-width: 44ch; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; }
.auth-points svg { flex: none; margin-top: 1px; color: var(--sage); width: 18px; height: 18px; padding: 3px; box-sizing: content-box; border-radius: 50%; background: rgba(143, 174, 150, .14); }
.auth-foot { font-size: 12px; color: #8C9AB0; letter-spacing: .02em; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .08); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--ground); background-image: radial-gradient(900px 500px at 100% 0, #E6EEEE, transparent 60%); }
.login { width: 100%; max-width: 430px; }
.login .card { padding: 36px 34px 32px; display: flex; flex-direction: column; gap: 16px; border-radius: 18px; box-shadow: 0 1px 2px rgba(20, 33, 61, .04), 0 30px 60px -28px rgba(20, 33, 61, .3); position: relative; overflow: hidden; }
.login .card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--navy), var(--petrol), var(--sage)); }
.login h1 { font-size: 29px; }
.login p { margin: 0; color: var(--ink-2); }
.login .eyebrow, .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--petrol); }
.login input { min-height: 48px; font-size: 15.5px; border-radius: 10px; }
.login input.code { letter-spacing: .45em; font-size: 24px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy); }
.login button.primary { min-height: 48px; font-size: 15px; border-radius: 10px; }
.login .legal { font-size: 12px; color: var(--muted); text-align: center; margin: 18px auto 0; max-width: 46ch; }
.auth-mobile-logos { display: none; }
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form { align-items: flex-start; padding: 0 16px 40px; background-image: none; }
  .auth-mobile-logos {
    display: flex; align-items: center; justify-content: center; margin: 0 -34px 6px; padding: 26px 20px 22px;
    background: linear-gradient(180deg, #F7F9F8, #fff); border-bottom: 1px solid var(--line-2);
  }
  .auth-mobile-logos img.cc { width: 220px; height: auto; }
  .auth-mobile-logos img.borrelli, .auth-mobile-logos img.legality { height: 30px; width: auto; }
  .login .card { margin-top: 24px; padding: 0 22px 26px; }
  .login .card::before { z-index: 1; }
  .login .card > .auth-mobile-logos { margin: 0 -22px 6px; }
}

@media print { body { display: none; } }

/* App installabile */
.install { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); font-size: 13px; color: var(--ink-2); margin-top: 16px; box-shadow: var(--shadow-1); }
.install img { border-radius: 10px; flex: none; border: 1px solid var(--line); }
.install b { color: var(--navy); }

/* Margini sicuri su iPhone quando l'app è aperta a tutto schermo */
.topbar { padding-top: env(safe-area-inset-top); padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
.auth-form { padding-top: max(48px, env(safe-area-inset-top)); padding-bottom: max(48px, env(safe-area-inset-bottom)); }
.viewer-bar { padding-top: max(10px, env(safe-area-inset-top)); }
@media (display-mode: standalone) { body { -webkit-user-select: none; user-select: none; } input, textarea { -webkit-user-select: text; user-select: text; } }

/* =====================================================================
   Composizione Crisi – componenti specifici
   ===================================================================== */
.cc-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; padding: 10px 0; }
.cc-brand:hover { color: #fff; }
.cc-brand img { flex: none; }
.cc-brand > span { display: flex; flex-direction: column; font-family: var(--brandfont); font-weight: 600; font-size: 17px; letter-spacing: .005em; line-height: 1.1; }
.cc-brand b { display: block; font-family: var(--brandfont); font-weight: 600; font-size: 17.5px; line-height: 1.1; letter-spacing: .005em; }
.cc-brand small { display: block; font-family: var(--sans); font-weight: 500; font-size: 10.5px; color: #A9C4AE; letter-spacing: .1em; text-transform: uppercase; margin-top: 3px; }
.topnav { display: flex; gap: 2px; margin-left: 18px; align-self: stretch; }
.topnav a {
  display: flex; align-items: center; padding: 0 14px; position: relative;
  text-decoration: none; color: rgba(255, 255, 255, .72); font-weight: 500; font-size: 13.5px;
  transition: color .15s ease;
}
.topnav a:hover { color: #fff; }
.topnav a[aria-current=page] { color: #fff; }
.topnav a[aria-current=page]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--sage); z-index: 1; }
.topbar #user-box button, .topbar #user-box .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); color: #fff; box-shadow: none; min-height: 34px; }
.topbar #user-box button:hover { background: rgba(255, 255, 255, .16); }
.topbar #user-box { color: rgba(255, 255, 255, .8); font-size: 13px; }

/* Riquadri numerici */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 14px; }
@media (min-width: 700px) { .tiles:has(> .tile:nth-child(5)) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  padding: 16px 18px 15px; display: flex; flex-direction: column; gap: 5px; text-decoration: none; color: var(--ink);
  position: relative; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sage); opacity: .85; }
.tiles > .tile:nth-child(4n+1)::before { background: var(--navy); }
.tiles > .tile:nth-child(4n+2)::before { background: var(--petrol); }
.tiles > .tile:nth-child(4n+3)::before { background: var(--sage); }
.tiles > .tile:nth-child(4n+4)::before { background: #5C8E95; }
a.tile:hover { border-color: #B9CFD1; box-shadow: 0 2px 4px rgba(20, 33, 61, .05), 0 14px 28px -14px rgba(20, 33, 61, .25); transform: translateY(-1px); color: var(--ink); }
.tile > span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.tile b { font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; color: var(--navy); letter-spacing: -.01em; line-height: 1.2; }
.tile .small { font-size: 12px; }
.tile-inline { display: flex; align-items: baseline; gap: 8px; }
.tile-inline b { font-size: 26px; font-family: var(--serif); color: var(--navy); }
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--petrol), var(--sage)); }

/* Fasi della procedura */
.fasi { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.fase { position: relative; display: block; text-align: left; padding: 22px 10px 2px 0; border: 0; background: none; border-radius: 0; min-height: 0; font-weight: 400; color: var(--muted); box-shadow: none; }
.fase:hover { background: none; }
.fase::before { content: ""; position: absolute; top: 7px; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--line); }
.fase.done::before { background: var(--petrol); }
.fase.now::before { background: linear-gradient(90deg, var(--petrol) 50%, var(--line) 50%); }
.fase .dot { position: absolute; top: 0; left: 0; width: 17px; height: 17px; border-radius: 50%; background: var(--card); border: 3px solid var(--line); z-index: 1; }
.fase.done .dot { background: var(--petrol); border-color: var(--petrol); box-shadow: inset 0 0 0 2px #fff; }
.fase.now .dot { border-color: var(--petrol); background: var(--sage); box-shadow: 0 0 0 4px rgba(31, 111, 120, .16); }
.fase b { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.fase.done b { color: var(--navy); }
.fase.now b { font-weight: 700; color: var(--navy); }
.fase:hover b { color: var(--petrol); }
@media (max-width: 760px) { .fasi { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; } }

/* Termini e scadenze */
.terms { display: flex; flex-direction: column; padding-top: 4px; padding-bottom: 4px; }
.term { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.term:last-child { border-bottom: 0; }
.term.past { opacity: .62; }
.term .date {
  text-align: center; border-radius: 10px; padding: 6px 0 5px; line-height: 1.05; font-variant-numeric: tabular-nums;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-1); overflow: hidden; position: relative;
}
.term .date::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--petrol); }
.term .date b { display: block; font-family: var(--serif); font-size: 20px; color: var(--navy); margin-top: 2px; }
.term .date small { font-size: 9.5px; font-weight: 600; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; }
.term h3 { margin: 0; font-size: 14px; color: var(--navy); }
.term p { margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }
.term .norm { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--petrol-dark); font-family: var(--mono); background: var(--petrol-soft); padding: 1px 7px; border-radius: 5px; }
.term-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
@media (max-width: 520px) { .term { grid-template-columns: 50px minmax(0, 1fr); } .term-right { grid-column: 2; align-items: center; flex-direction: row; flex-wrap: wrap; } }

/* Checklist art. 17 */
.ck { display: grid; grid-template-columns: 110px minmax(0, 1fr) 170px; gap: 14px; align-items: start; padding: 16px 22px; border-top: 1px solid var(--line-2); transition: background-color .12s ease; }
.ck:first-child { border-top: 0; }
.ck:hover { background: #FBFCFC; }
.ck .n { justify-self: start; font-size: 11px; font-weight: 600; color: var(--petrol-dark); font-family: var(--mono); background: var(--petrol-soft); padding: 2px 8px; border-radius: 5px; margin-top: 1px; }
.ck h3 { margin: 0; font-size: 14px; }
.ck p { margin: 0; font-size: 12.5px; color: var(--muted); }
.ck .doc-sel { max-width: 340px; }
.ck input[type=text] { min-width: 160px; }
@media (max-width: 760px) { .ck { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; } }

/* Compilatore */
.comp { display: grid; grid-template-columns: 270px minmax(0, .9fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
@media (max-width: 1200px) { .comp { grid-template-columns: 250px minmax(0, 1fr); } .comp > .col { grid-column: 1 / -1; } }
@media (max-width: 760px) { .comp { grid-template-columns: minmax(0, 1fr); } }
.doclist { display: flex; flex-direction: column; overflow: hidden; padding: 6px; }
.doclist button {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; justify-content: stretch; text-align: left;
  border: 0; border-radius: 9px; padding: 10px 12px; min-height: 0; font-weight: 500; background: none; box-shadow: none; color: var(--ink);
}
.doclist button + button { margin-top: 1px; }
.doclist button:hover { background: var(--ground); }
.doclist button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.doclist button[aria-pressed="true"] .n, .doclist button[aria-pressed="true"] small { color: #A9C4AE; }
.doclist .n { font-size: 12px; color: var(--petrol); font-family: var(--mono); padding-top: 1px; font-weight: 600; }
.doclist small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.paper {
  background: #fff; border: 1px solid #E3E6E6; border-radius: 3px; padding: 40px 46px 40px 42px;
  font: 15px/1.6 Garamond, "EB Garamond", "Times New Roman", serif; color: #1b1b1b;
  box-shadow: 0 1px 1px rgba(20, 33, 61, .04), 0 10px 30px -12px rgba(20, 33, 61, .25), 0 0 0 6px #F0F3F2;
  overflow-wrap: anywhere;
}
.paper p { margin: 0 0 10px; text-align: justify; }
.paper p.c { text-align: center; }
.paper p.it { font-style: italic; text-align: left; }
.paper p.dest { text-align: left; line-height: 1.3; }
.paper p.li { padding-left: 22px; text-indent: -14px; }
.paper p.sig { text-align: right; line-height: 1.35; margin-top: 18px; }
.paper .lh { display: flex; justify-content: space-between; gap: 12px; font: 12px/1.3 var(--sans); color: #5F6B7E; border-bottom: 1px solid #DCE3E3; padding-bottom: 8px; margin-bottom: 18px; }
.paper .f.empty { background: #FAD4D4; color: #7A1F1F; border-radius: 2px; padding: 0 2px; }
.paper .tw { overflow-x: auto; margin: 6px 0 12px; }
.paper table { font-size: 12.5px; border-collapse: collapse; width: 100%; }
.paper th, .paper td { border: 1px solid #A9B3B5; padding: 4px 6px; text-transform: none; letter-spacing: 0; color: #1b1b1b; background: none; font-size: 12.5px; white-space: normal; }
.paper th { background: #E8ECEC; font-weight: 600; }
.paper tr:hover td { background: none; }
.paper tr.tot td { font-weight: 700; }
@media (max-width: 560px) { .paper { padding: 24px 20px; font-size: 14px; } }

/* =====================================================================
   Telefono e tablet
   ===================================================================== */
@media (max-width: 860px) {
  main { padding: 20px 16px 64px; gap: 16px; }
  h1 { font-size: 26px; }
  .topbar { gap: 0 12px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topnav {
    order: 3; flex: 1 0 100%; margin: 0 -16px; padding: 0 8px; height: 42px; overflow-x: auto; scrollbar-width: none;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { padding: 0 12px; }
  .topnav a[aria-current=page]::after { left: 12px; right: 12px; }
  .card-head { padding: 13px 16px; }
  .card-body { padding: 15px 16px; }
  th { padding: 10px 12px; }
  td { padding: 11px 12px; }
}
@media (max-width: 560px) {
  .cc-brand small { display: none; }
  .cc-brand b, .cc-brand > span { font-size: 16px; }
  .avatar { padding: 0 5px; font-size: 0; gap: 0; }
  .avatar::before { width: 24px; height: 24px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px 13px 12px 15px; }
  .tile b { font-size: 18px; }
  .tile > span { font-size: 10px; letter-spacing: .06em; }
  button, .btn { min-height: 40px; }
  dialog { width: calc(100% - 16px); border-radius: 14px; }
  dialog form { padding: 0 18px 18px; }
  dialog form > h2:first-child { margin: 0 -18px 2px; padding: 16px 18px 13px; font-size: 18px; }
  dialog form > .actions:last-child { margin: 6px -18px -18px; padding: 12px 18px; }
  dialog form > .actions:last-child button { flex: 1; }
  .drop { padding: 16px; font-size: 13px; }
  .table-wrap tbody td:first-child { min-width: 9.5em; }
  #toast { left: 16px; right: 16px; transform: none; max-width: none; text-align: center; animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
