:root {
  --ink: #08182f;
  --ink-soft: #5b6575;
  --paper: #f7f8fb;
  --surface: #ffffff;
  --line: #dfe4eb;
  --blue: #155db2;
  --soft: #eef3f9;
  --red: #bd1118;
  --red-dark: #8f0d12;
  --green: #176b50;
  --amber: #9b5c08;
  --shadow: 0 24px 70px rgba(8, 21, 39, .10);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% 5%, rgba(21, 93, 178, .13), transparent 28rem),
    radial-gradient(circle at 7% 34%, rgba(189, 17, 24, .07), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
::selection { color: #fff; background: var(--blue); }
:focus-visible { outline: 3px solid rgba(21, 93, 178, .35); outline-offset: 3px; }
.page-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .28;
  background-image: linear-gradient(rgba(8,24,47,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(8,24,47,.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 72%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 82px;
  padding: 15px clamp(22px, 5vw, 80px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(223, 228, 235, .82);
  background: rgba(247, 248, 251, .92);
  box-shadow: 0 8px 24px rgba(8, 21, 39, .04);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; font-weight: 800; }
.brand img { display: block; width: 190px; height: auto; }
.brand span { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); background: var(--surface); font-size: .82rem; letter-spacing: .02em; }
.site-header nav { display: flex; align-items: center; gap: 22px; }
.site-header nav > a:not(.button) { position: relative; text-decoration: none; font-weight: 750; }
.site-header nav > a:not(.button)::after { position: absolute; right: 100%; bottom: -7px; left: 0; height: 2px; background: var(--red); content: ""; transition: right .18s ease; }
.site-header nav > a:not(.button):hover::after { right: 0; }
.inline-form { display: inline-flex; margin: 0; }
.nav-button { padding: 5px 0; border: 0; color: var(--ink); background: transparent; cursor: pointer; font-weight: 750; }
.account-strip { display: flex; justify-content: flex-end; gap: 24px; padding: 9px clamp(22px, 5vw, 80px); background: var(--ink); color: #fff; font-size: .86rem; }
.account-warning { color: #ffd89b; font-weight: 800; }

main { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 76px 0 108px; }
h1, h2 { line-height: 1.08; margin-top: 0; color: var(--ink); }
h1 { font-size: clamp(3rem, 6.8vw, 5.8rem); font-weight: 850; letter-spacing: -.058em; }
h2 { font-size: 1.45rem; }
p { color: var(--ink-soft); }
.eyebrow { display: inline-block; margin-bottom: 22px; color: var(--red); font-size: .78rem; font-weight: 800; letter-spacing: .19em; }
.eyebrow::after { content: ""; display: block; height: 2px; width: 36px; margin-top: 9px; border-radius: 1px; background: #cdd6e4; }
.button {
  display: inline-flex;
  min-height: 48px;
  padding: 11px 22px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 16px 38px rgba(8, 21, 39, .18);
  text-decoration: none;
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.button:hover { background: #102742; border-color: #102742; box-shadow: 0 18px 42px rgba(8, 21, 39, .23); transform: translateY(-1px); }
.button-small { min-height: 39px; padding: 7px 16px; }
.button-full { width: 100%; }
.text-link, .back-link { color: var(--blue); font-weight: 800; text-underline-offset: 4px; }

.hero { max-width: 900px; padding: 28px 0 74px; animation: reveal .55s ease-out both; }
.hero h1 { max-width: 840px; margin-bottom: 28px; }
.hero h1 em { font-style: normal; color: var(--ink); }
.hero-copy { max-width: 700px; font-size: 1.22rem; }
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 35px; }
.promise-grid { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 12px 34px rgba(8, 21, 39, .05); }
.promise-grid article { min-height: 245px; padding: 32px; border-right: 1px solid var(--line); }
.promise-grid article:last-child { border-right: 0; }
.promise-grid article > span { display: inline-grid; min-width: 44px; height: 36px; padding: 0 10px; place-items: center; border-radius: 999px; color: #fff; background: #0d2440; font-size: .78rem; font-weight: 850; letter-spacing: .08em; }
.promise-grid h2 { margin: 44px 0 10px; font-size: 2rem; letter-spacing: -.035em; }
.security-note { margin-top: 24px; padding: 22px 26px; border-left: 2px solid #cdd6e4; background: #fff; box-shadow: 0 10px 30px rgba(8, 21, 39, .04); }
.security-note p { margin: 4px 0 0; }
.small-note { margin-top: 32px; }

.form-shell, .login-shell { display: grid; grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr); gap: clamp(42px, 7vw, 100px); align-items: start; }
.form-intro { position: sticky; top: 30px; }
.form-intro h1, .login-shell h1 { font-size: clamp(2.4rem, 5vw, 4.3rem); }
.form-card { padding: clamp(26px, 4vw, 46px); border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.compact-card { max-width: 520px; }
.form-card label { display: block; margin-bottom: 20px; color: var(--ink); font-weight: 720; }
.form-card label small { float: right; color: #6f7784; font-weight: 500; }
.form-card input, .form-card select, .form-card textarea {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid #cbd6e2;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.form-card textarea { resize: vertical; }
.form-card input:focus, .form-card select:focus, .form-card textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,93,178,.12); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-card .check-row { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-size: .91rem; font-weight: 550; }
.form-card .check-row input { width: 17px; margin: 3px 0 0; }
.muted-check { color: #5f6876 !important; }
.form-error, .flash { margin-bottom: 22px; padding: 14px 16px; border-left: 4px solid var(--red); background: #fff0f0; color: #7d1115; font-weight: 700; }
.flash { margin-bottom: 32px; }
.flash-success { border-color: var(--green); background: #edf8f3; color: #12553f; }
.flash-warning { border-color: var(--amber); background: #fff6e6; color: #6f4308; }
.form-foot { margin: 18px 0 0; text-align: center; font-size: .92rem; }

.page-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 44px; }
.page-heading h1 { margin-bottom: 12px; font-size: clamp(3rem, 5vw, 4.7rem); }
.page-heading p { margin: 0; }
.ticket-list { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 12px 34px rgba(8, 21, 39, .05); }
.ticket-row { display: grid; grid-template-columns: 1fr auto; gap: 30px; padding: 27px 8px; border-bottom: 1px solid var(--line); text-decoration: none; transition: padding .18s ease, background .18s ease; }
.ticket-row { padding-left: 28px; padding-right: 28px; }
.ticket-row:hover { padding-left: 36px; padding-right: 36px; background: var(--soft); }
.ticket-row h2 { margin: 7px 0; font-size: 1.55rem; }
.ticket-row p { margin: 0; }
.ticket-number { color: var(--red-dark); font-size: .77rem; font-weight: 850; letter-spacing: .09em; }
.ticket-meta { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 16px; }
.ticket-meta time { color: #68717e; font-size: .84rem; }
.status { display: inline-flex; padding: 6px 10px; border: 1px solid #aeb7c4; border-radius: 999px; color: var(--ink); background: #eef1f5; font-size: .78rem; font-weight: 800; }
.status-in_progress, .status-triage { border-color: #d28a29; background: #fff4df; color: #744704; }
.status-resolved, .status-closed { border-color: #4d987e; background: #e9f7f1; color: #14543f; }
.empty-state { padding: 70px 30px; border: 1px dashed #b8c6d5; border-radius: 18px; text-align: center; background: rgba(255,255,255,.72); }
.empty-state > span { color: #5b6575; font-weight: 850; letter-spacing: .2em; }
.verification-banner { margin-bottom: 30px; padding: 22px 25px; border-left: 2px solid var(--amber); background: #fff6e6; }
.verification-banner p { margin: 5px 0 0; }
.banner-action { margin: 16px 0 0; }
.verification-state { max-width: 820px; margin: 40px auto; }
.verification-state h1 { margin: 20px 0; font-size: clamp(2.5rem, 6vw, 4.8rem); }

.back-link { display: inline-block; margin-bottom: 40px; }
.ticket-heading { display: flex; align-items: start; justify-content: space-between; gap: 30px; padding-bottom: 38px; border-bottom: 1px solid var(--line); }
.ticket-heading h1 { margin: 10px 0; font-size: clamp(2.3rem, 5vw, 4.2rem); }
.ticket-heading p { margin: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr); gap: 24px; margin-top: 24px; }
.detail-card { padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.88); box-shadow: 0 12px 34px rgba(8, 21, 39, .05); }
.preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }
.facts-card dl { margin: 0; }
.facts-card dt { margin-top: 17px; color: #697282; font-size: .76rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.facts-card dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.operator-update { margin-top: 24px; padding: 28px 32px; border-left: 5px solid var(--green); background: #edf8f3; }
.operator-update > span { color: var(--green); font-size: .77rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }

.site-footer { display: flex; justify-content: space-between; gap: 30px; padding: 34px clamp(22px, 5vw, 80px); border-top: 1px solid rgba(255, 255, 255, .14); background: var(--ink); color: #fff; }
.site-footer div:first-child { display: flex; flex-direction: column; }
.site-footer span { color: #bcc6d3; font-size: .9rem; }
.footer-links { display: flex; align-items: center; gap: 22px; }
.footer-links a { color: #fff; font-size: .88rem; }

@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 850px) {
  .site-header { align-items: flex-start; }
  .site-header nav { flex-wrap: wrap; justify-content: flex-end; gap: 12px 17px; }
  .brand span { display: none; }
  main { width: min(100% - 28px, 700px); padding-top: 48px; }
  .promise-grid, .form-shell, .login-shell, .detail-grid { grid-template-columns: 1fr; }
  .promise-grid article { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .promise-grid article:last-child { border-bottom: 0; }
  .promise-grid h2 { margin-top: 25px; }
  .form-intro { position: static; }
  .page-heading, .ticket-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .site-header { min-height: 70px; padding: 12px 15px; }
  .brand img { width: 126px; }
  .site-header nav > a:not(.button) { display: none; }
  .account-strip { padding: 7px 15px; justify-content: space-between; gap: 10px; }
  .hero { padding-top: 15px; }
  .hero-actions, .site-footer, .footer-links { align-items: stretch; flex-direction: column; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .form-card { padding: 23px 18px; }
  .ticket-row { grid-template-columns: 1fr; }
  .ticket-meta { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
/* Dettaglio ticket: conversazione, messaggi, evidenze */
.button-outline {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  box-shadow: none;
}
.button-outline:hover { background: var(--soft); border-color: var(--blue); color: var(--ink); box-shadow: none; transform: none; }
.conversation-card, .evidence-card { margin-top: 22px; }
.conversation-card h2, .evidence-card h2 { margin: 0 0 16px; }
.field-hint { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.empty-hint { margin: 0 0 8px; color: var(--ink-soft); }
.reminder-form { margin-top: 18px; }

.message-thread { list-style: none; margin: 0 0 22px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.message { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.message-customer { border-left: 4px solid var(--blue); }
.message-operator { border-left: 4px solid var(--green); background: var(--soft); }
.message-system { border-left: 4px solid var(--ink-soft); }
.message-reminder { border-left: 4px solid var(--amber); background: #fff8ee; }
.message-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.message-author { font-weight: 750; color: var(--ink); }
.message-meta time { color: var(--ink-soft); font-size: 13px; }
.message p { margin: 0; }

.stacked-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stacked-form label { font-weight: 700; color: var(--ink); }
.stacked-form textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; color: var(--ink); background: var(--surface); resize: vertical;
}
.stacked-form textarea:focus, .stacked-form input[type="file"]:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.attachment-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.attachment { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.attachment-name { font-weight: 700; overflow-wrap: anywhere; }
.attachment-state { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--ink-soft); }
.attachment-clean .attachment-state, .attachment-delivered .attachment-state { background: #e6f2ec; color: var(--green); }
.attachment-malicious .attachment-state, .attachment-rejected .attachment-state { background: #fdeaea; color: var(--red-dark); }
.attachment-time { margin-left: auto; color: var(--ink-soft); font-size: 13px; }

/* Honeypot field: real users must never see or focus it. */
.bot-trap {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Fix: i check-row non devono affiancarsi ai float (hint password) */
.form-card .check-row { clear: both; }
/* CAPTCHA della registrazione */
.captcha-box { display: block; margin: 10px 0 12px; }
.captcha-box img { display: block; border: 1px solid #cdd6e4; border-radius: 8px; background: #fff; }
.captcha-hint { margin: -6px 0 18px; font-size: .88rem; color: #5f6876; }
