/* ============================================================
   SNK & ALEXA - Base CSS (riusabile in tutto il sistema)
   Elegante + Sportivo • Mobile-first • Accessibile
   ============================================================ */

/* ---------- CSS Reset (light) ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body { margin: 0; }

img, picture, video, canvas, svg { display: block; max-width: 100%; }

input, button, textarea, select { font: inherit; }

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(64, 232, 255, 0.45);
  outline-offset: 2px;
  border-radius: 10px;
}

:root{
  /* Palette sportiva/elegante */
  --bg-0: #070b12;
  --bg-1: #0b1220;
  --bg-2: #0f1b31;

  --card: rgba(255,255,255,0.06);
  --card-strong: rgba(255,255,255,0.09);
  --stroke: rgba(255,255,255,0.12);
  --stroke-strong: rgba(255,255,255,0.18);

  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.70);
  --muted-2: rgba(255,255,255,0.58);

  --accent: #40e8ff; /* ciano sportivo */
  --accent-2: #7c5cff; /* viola neon */
  --ok: #39d98a;
  --warn: #ffd166;
  --danger: #ff5c7a;

  --shadow: 0 14px 40px rgba(0,0,0,0.45);
  --shadow-soft: 0 10px 24px rgba(0,0,0,0.35);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 10px;

  --container: 1120px;
  --gutter: 18px;

  --header-h: 200px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --t-xxl: clamp(1.8rem, 2.8vw, 2.6rem);
  --t-xl:  clamp(1.3rem, 1.8vw, 1.8rem);
  --t-lg:  1.14rem;
  --t-md:  1rem;
  --t-sm:  0.92rem;
  --t-xs:  0.84rem;

  --line: 1.5;

  --btn-h: 46px;
  --btn-h-sm: 38px;
  --pad: 16px;
  --pad-sm: 12px;
}

/* Dark by default; migliora se il browser forza light */
@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #f5f7fb;
    --bg-1: #ffffff;
    --bg-2: #eef3ff;

    --card: rgba(10,16,24,0.05);
    --card-strong: rgba(10,16,24,0.07);
    --stroke: rgba(10,16,24,0.10);
    --stroke-strong: rgba(10,16,24,0.16);

    --text: rgba(10,16,24,0.92);
    --muted: rgba(10,16,24,0.68);
    --muted-2: rgba(10,16,24,0.55);

    --shadow: 0 14px 40px rgba(10,16,24,0.12);
    --shadow-soft: 0 10px 24px rgba(10,16,24,0.10);
  }
}

/* ---------- Base ---------- */
body{
  font-family: var(--font);
  color: var(--text);
  line-height: var(--line);
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(64,232,255,0.22), transparent 55%),
    radial-gradient(900px 600px at 90% 0%, rgba(124,92,255,0.20), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  min-height: 100dvh;
}

/* Safe area iOS */
.site-header, .site-footer, .site-main { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

.container{
  width: min(var(--container), calc(100% - (var(--gutter) * 2)));
  margin: 0 auto;
}

.skip-link{
  position: absolute;
  left: -999px;
  top: 10px;
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 9999;
}
.skip-link:focus{ left: 10px; }

.muted { color: var(--muted); }
.text-accent{ color: var(--accent); }

/* ---------- Header / Nav ---------- */
.site-header{
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklab, var(--bg-1) 86%, transparent);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
}
.header-inner{
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo{
  width: 150px;
  height: 150px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(64,232,255,0.22), rgba(124,92,255,0.18));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.brand-logo img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand-logo.logo-fallback .logo-mark{
  display: grid;
}
.logo-mark{
  display: none;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text);
  font-size: 0.95rem;
}

.brand-text{ min-width: 0; }
.brand-title{
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-subtitle{
  font-size: var(--t-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-nav{
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}
.nav-link:hover{
  color: var(--text);
  background: var(--card);
  border-color: var(--stroke);
}
.nav-link.active{
  color: var(--text);
  background: color-mix(in oklab, var(--accent) 12%, var(--card));
  border-color: color-mix(in oklab, var(--accent) 36%, var(--stroke));
}

/* Hamburger (mobile) */
.nav-toggle{
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}
.nav-toggle:hover{ background: var(--card-strong); }

.nav-toggle-lines{
  width: 20px;
  height: 2px;
  background: var(--text);
  display: block;
  position: relative;
  border-radius: 10px;
  margin: 0 auto;
}
.nav-toggle-lines::before,
.nav-toggle-lines::after{
  content: "";
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 10px;
}
.nav-toggle-lines::before{ top: -6px; }
.nav-toggle-lines::after{ top: 6px; }

/* Mobile nav behavior */
@media (max-width: 900px){
  .nav-toggle{ display: inline-grid; place-items: center; }
  .site-nav{
    position: fixed;
    top: calc(var(--header-h) + env(safe-area-inset-top));
    left: 0; right: 0;
    padding: 14px;
    background: color-mix(in oklab, var(--bg-1) 92%, transparent);
    border-bottom: 1px solid var(--stroke);
    backdrop-filter: blur(12px);
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;

    transform: translateY(-14px);
    opacity: 0;
    pointer-events: none;
    transition: 180ms ease;
  }
  .site-nav.is-open{
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-link{
    padding: 12px 14px;
    border: 1px solid var(--stroke);
    background: var(--card);
    color: var(--text);
  }
  body.nav-open{
    overflow: hidden; /* evita scroll dietro */
  }
}

/* ---------- Main ---------- */
.site-main{ padding-bottom: 40px; }

/* Hero */
.hero{
  padding: 26px 0 18px;
}
.hero-inner{
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  align-items: stretch;
}

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

.kicker{
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in oklab, var(--accent) 70%, var(--muted));
  margin: 0 0 10px;
}

.hero-title{
  margin: 0;
  font-size: var(--t-xxl);
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.hero-subtitle{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--t-md);
  max-width: 58ch;
}

.hero-actions{
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Chips */
.chips{ display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.chip{
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-weight: 700;
  font-size: var(--t-xs);
}

/* Sections */
.section{ padding: 22px 0; }
.section-muted{
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--card) 85%, transparent) 40%, transparent);
}
.section-head{ margin-bottom: 12px; }
.section-title{
  margin: 0;
  font-size: var(--t-xl);
  letter-spacing: -0.01em;
}
.section-subtitle{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--t-sm);
}

/* ---------- Layout utilities ---------- */
.stack{ display: grid; }
.stack-row{ display: flex; align-items: center; }
.gap-sm{ gap: 10px; }
.wrap{ flex-wrap: wrap; }
.divider{
  height: 1px;
  background: var(--stroke);
  margin: 16px 0;
}

/* Grid */
.grid{ display: grid; gap: 14px; }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px){
  .grid-2, .grid-3{ grid-template-columns: 1fr; }
}

/* ---------- Card ---------- */
.card{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.card-header{
  padding: 16px 16px 0;
}
.card-title{
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.card-subtitle{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--t-sm);
}
.card-content{
  padding: 16px;
}
.hover-lift{ transition: transform 160ms ease, border-color 160ms ease, background 160ms ease; }
.hover-lift:hover{
  transform: translateY(-2px);
  border-color: var(--stroke-strong);
  background: color-mix(in oklab, var(--card) 65%, transparent);
}

/* ---------- Buttons ---------- */
.btn{
  height: var(--btn-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: 160ms ease;
}
.btn:disabled{ opacity: .6; cursor: not-allowed; }

.btn-primary{
  background: linear-gradient(135deg, rgba(64,232,255,0.95), rgba(124,92,255,0.92));
  border-color: rgba(255,255,255,0.10);
  color: rgba(5, 10, 18, 0.92);
  box-shadow: var(--shadow);
}
.btn-primary:hover{ filter: saturate(1.05) brightness(1.02); transform: translateY(-1px); }

.btn-ghost{
  background: var(--card);
  border-color: var(--stroke);
  color: var(--text);
}
.btn-ghost:hover{
  background: var(--card-strong);
  border-color: var(--stroke-strong);
}

.btn-soft{
  background: color-mix(in oklab, var(--accent) 10%, var(--card));
  border-color: color-mix(in oklab, var(--accent) 24%, var(--stroke));
  color: var(--text);
}
.btn-soft:hover{ border-color: color-mix(in oklab, var(--accent) 36%, var(--stroke)); }

.btn-link{
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: color-mix(in oklab, var(--accent) 80%, var(--text));
  font-weight: 900;
}
.btn-link:hover{ text-decoration: underline; text-underline-offset: 4px; }

.btn-sm{
  height: var(--btn-h-sm);
  border-radius: 12px;
  padding: 0 12px;
  font-size: var(--t-sm);
}

/* ---------- Badges ---------- */
.badge{
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-weight: 900;
  font-size: var(--t-xs);
}
.badge-ok{
  background: color-mix(in oklab, var(--ok) 18%, var(--card));
  border-color: color-mix(in oklab, var(--ok) 34%, var(--stroke));
  color: color-mix(in oklab, var(--ok) 85%, var(--text));
}
.badge-warn{
  background: color-mix(in oklab, var(--warn) 18%, var(--card));
  border-color: color-mix(in oklab, var(--warn) 34%, var(--stroke));
  color: color-mix(in oklab, var(--warn) 88%, var(--text));
}
.badge-danger{
  background: color-mix(in oklab, var(--danger) 18%, var(--card));
  border-color: color-mix(in oklab, var(--danger) 34%, var(--stroke));
  color: color-mix(in oklab, var(--danger) 88%, var(--text));
}

/* ---------- Alerts ---------- */
.alert{
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
}
.alert strong{ font-weight: 950; }
.alert-info{
  background: color-mix(in oklab, var(--accent) 12%, var(--card));
  border-color: color-mix(in oklab, var(--accent) 28%, var(--stroke));
}

/* ---------- Forms ---------- */
.form{ display: grid; gap: 12px; }
.form-row{ display: grid; gap: 8px; }

.label{
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: 900;
}
.hint{
  font-size: var(--t-xs);
  color: var(--muted-2);
}

.input,
.select,
.textarea{
  width: 100%;
  background: color-mix(in oklab, var(--bg-1) 40%, var(--card));
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px 14px;
  transition: 160ms ease;
}
.textarea{ min-height: 110px; resize: vertical; }

.input::placeholder,
.textarea::placeholder{ color: var(--muted-2); }

.input:focus,
.select:focus,
.textarea:focus{
  border-color: color-mix(in oklab, var(--accent) 40%, var(--stroke));
  box-shadow: 0 0 0 4px rgba(64,232,255,0.12);
  outline: none;
}

.input-group{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
@media (max-width: 520px){
  .input-group{ grid-template-columns: 1fr; }
}

/* Checkbox / radio baseline */
.checkline{
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: var(--t-sm);
}
.checkline input{ width: 18px; height: 18px; }

/* ---------- Tables ---------- */
.table-wrap{
  width: 100%;
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--card);
}
.table{
  width: 100%;
  border-collapse: collapse;
  min-width: 680px; /* aiuta su mobile con scroll orizzontale */
}
.table th, .table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
  vertical-align: top;
}
.table th{
  position: sticky;
  top: 0;
  background: color-mix(in oklab, var(--bg-1) 75%, var(--card));
  color: var(--muted);
  font-weight: 950;
  letter-spacing: 0.02em;
}
.table tr:hover td{
  background: color-mix(in oklab, var(--card) 65%, transparent);
}
.table .num{ text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---------- Images / Media ---------- */
.img-frame{
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  overflow: hidden;
  background: var(--card);
}
.img-frame img{ width: 100%; height: auto; object-fit: cover; }

/* Avatar */
.avatar{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  overflow: hidden;
}

/* ---------- Attachments ---------- */
.attachment-list{ display: grid; gap: 10px; }
.attachment{
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: color-mix(in oklab, var(--bg-1) 35%, var(--card));
}
.attachment-icon{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 950;
  letter-spacing: 0.06em;
  color: rgba(5,10,18,0.92);
  background: linear-gradient(135deg, rgba(64,232,255,0.95), rgba(124,92,255,0.90));
}
.attachment-meta{ min-width: 0; }
.attachment-name{
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-sub{
  color: var(--muted);
  font-size: var(--t-xs);
  margin-top: 3px;
}

/* ---------- Measurements / KPI ---------- */
.metrics-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.metric{
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: color-mix(in oklab, var(--bg-1) 35%, var(--card));
}
.metric-label{
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 900;
}
.metric-value{
  margin-top: 6px;
  font-family: var(--mono);
  font-weight: 950;
  font-size: 1.25rem;
}
.measurements{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.measure{
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: color-mix(in oklab, var(--bg-1) 35%, var(--card));
}
.measure-name{
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 950;
  letter-spacing: 0.02em;
}
.measure-value{
  margin-top: 6px;
  font-weight: 950;
  font-family: var(--mono);
  font-size: 1.18rem;
}
.measure-unit{
  color: var(--muted);
  font-size: 0.95rem;
  margin-left: 4px;
}
@media (max-width: 420px){
  .metrics-grid, .measurements{ grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.site-footer{
  margin-top: 12px;
  padding: 18px 0 26px;
  border-top: 1px solid var(--stroke);
  background: color-mix(in oklab, var(--bg-1) 70%, transparent);
}
.footer-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-links{ display: inline-flex; align-items: center; gap: 10px; }
.footer-link{
  color: var(--muted);
  font-weight: 900;
}
.footer-link:hover{ color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.dot{ color: var(--muted-2); }

/* ---------- Helpers (future) ---------- */
.hidden{ display: none !important; }
.center{ display: grid; place-items: center; }
.rounded{ border-radius: var(--radius) !important; }
.rounded-sm{ border-radius: var(--radius-sm) !important; }
.shadow{ box-shadow: var(--shadow) !important; }
.code{
  font-family: var(--mono);
  font-size: 0.92rem;
  background: color-mix(in oklab, var(--bg-1) 30%, var(--card));
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 2px 8px;
}

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .nav-toggle { display: none !important; }
  body{ background: #fff; color: #000; }
  .card, .table-wrap, .attachment{ box-shadow: none; }
}
/* ---------- Dialog / Popup ---------- */
dialog{
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  max-width: min(560px, calc(100% - 24px));
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

dialog::backdrop{
  background: rgba(7, 11, 18, 0.78);
  backdrop-filter: blur(4px);
}

dialog .dialog-card{
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  color: var(--text);
}

dialog .dialog-title{
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

dialog .dialog-subtitle{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--t-sm);
}

dialog .dialog-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

dialog .input,
dialog .select,
dialog .textarea{
  background: color-mix(in oklab, var(--bg-1) 40%, var(--card));
  color: var(--text);
  border: 1px solid var(--stroke);
}

dialog .label,
dialog .muted,
dialog strong{
  color: var(--text);
}

dialog form{
  margin: 0;
}

@media (max-width: 640px){
  dialog{
    max-width: calc(100% - 16px);
  }

  dialog .dialog-card{
    padding: 14px;
  }
}
.btn-danger{
  background: linear-gradient(135deg, rgba(255,92,122,0.95), rgba(255,120,120,0.92));
  border-color: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.96);
  box-shadow: var(--shadow);
}
.btn-danger:hover{
  filter: saturate(1.05) brightness(1.02);
  transform: translateY(-1px);
}