/* SitesLab Client Dashboard — design system v6
   Bianco assoluto e petrolio (#16404B). Tutta la scala di grigi è fredda,
   con una punta di petrolio dentro (niente grigi caldi): testi, bordi e
   superfici appartengono alla stessa famiglia cromatica del brand. Le card
   sono piatte, definite da bordi hairline — l'ombra esiste solo su modali e
   menu. La firma dell'app sono le "linee di marea" da carta nautica: scure
   nell'hero e nel login, in filigrana petrolio in fondo alla sidebar. */

@import url('https://api.fontshare.com/v2/css?f[]=general-sans@200,300,400,500,600,700&display=swap');

:root {
  /* Colore — ruoli chiari */
  --brand: #16404b;        /* colore primario: pillole attive, bottoni, focus, accenti */
  --brand-hover: #0f2e37;
  --brand-soft: rgba(22,64,75,0.07);
  --brand-soft-2: rgba(22,64,75,0.14);
  --ink-900: #0c2229;
  --ink-800: #16404b;
  --success-600: #0e5a49;
  --success-500: #12715b;  /* verde — solo stati positivi/attivo, non piu' il colore guida */
  --success-soft: #e4f3ee;
  --coral-500: #c1583e;    /* coppo di terracotta — priorita' alta / attenzione */
  --coral-soft: #f7e2da;
  --danger-500: #b23b3b;
  --danger-soft: #f6dfdc;

  /* Superfici — bianco assoluto; i grigi sono freddi, nella famiglia del petrolio */
  --page-bg: #ffffff;
  --surface: #ffffff;
  --surface-tertiary: #f2f5f5;
  --border: #e4e9e9;
  --border-soft: #eef1f1;
  --white: #ffffff;

  --text-primary: #182226;
  --text-secondary: #5c6b70;
  --text-tertiary: #97a4a8;

  --radius-lg: 12px;
  --radius: 8px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(11,31,38,0.04);
  --shadow: 0 2px 8px rgba(11,31,38,0.05);
  --shadow-lg: 0 14px 34px rgba(11,31,38,0.16);

  --font-display: 'General Sans', -apple-system, "Segoe UI", sans-serif;
  --font: 'General Sans', -apple-system, "Segoe UI", sans-serif;
  /* Segno distintivo: linee di marea/carta nautica, l'unica texture decorativa dell'app */
  --tide-lines: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='90' viewBox='0 0 240 90'%3E%3Cpath d='M0 20 C 20 10, 40 30, 60 20 S 100 10, 120 20 S 160 30, 180 20 S 220 10, 240 20' fill='none' stroke='white' stroke-opacity='0.16' stroke-width='1.2'/%3E%3Cpath d='M0 45 C 20 35, 40 55, 60 45 S 100 35, 120 45 S 160 55, 180 45 S 220 35, 240 45' fill='none' stroke='white' stroke-opacity='0.1' stroke-width='1.2'/%3E%3Cpath d='M0 70 C 20 60, 40 80, 60 70 S 100 60, 120 70 S 160 80, 180 70 S 220 60, 240 70' fill='none' stroke='white' stroke-opacity='0.07' stroke-width='1.2'/%3E%3C/svg%3E");
  /* Variante in filigrana petrolio, per superfici chiare (fondo sidebar) */
  --tide-lines-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='90' viewBox='0 0 240 90'%3E%3Cpath d='M0 20 C 20 10, 40 30, 60 20 S 100 10, 120 20 S 160 30, 180 20 S 220 10, 240 20' fill='none' stroke='%2316404B' stroke-opacity='0.18' stroke-width='1.2'/%3E%3Cpath d='M0 45 C 20 35, 40 55, 60 45 S 100 35, 120 45 S 160 55, 180 45 S 220 35, 240 45' fill='none' stroke='%2316404B' stroke-opacity='0.11' stroke-width='1.2'/%3E%3Cpath d='M0 70 C 20 60, 40 80, 60 70 S 100 60, 120 70 S 160 80, 180 70 S 220 60, 240 70' fill='none' stroke='%2316404B' stroke-opacity='0.06' stroke-width='1.2'/%3E%3C/svg%3E");

  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #4fa3b8;
  --brand-hover: #6fb8c9;
  --brand-soft: rgba(79,163,184,0.14);
  --brand-soft-2: rgba(79,163,184,0.24);
  --ink-900: #eef3f3;
  --ink-800: #dce6e6;
  --success-600: #4bc79a;
  --success-500: #3aa47f;
  --success-soft: rgba(58,164,127,0.16);
  --coral-500: #e08a6e;
  --coral-soft: rgba(224,138,110,0.16);
  --danger-500: #e0716f;
  --danger-soft: rgba(224,113,111,0.16);

  --page-bg: #14191b;
  --surface: #1c2427;
  --surface-tertiary: #242e31;
  --border: #33403f;
  --border-soft: #2a3536;
  --white: #1c2427;

  --text-primary: #eaf0ef;
  --text-secondary: #a7b4b3;
  --text-tertiary: #71807f;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 2px 8px rgba(0,0,0,0.28);
  --shadow-lg: 0 14px 34px rgba(0,0,0,0.45);

  color-scheme: dark;
}

@keyframes tide-drift {
  from { background-position-x: 0; }
  to { background-position-x: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0 0 0.4em; font-family: var(--font-display); color: var(--ink-900); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; letter-spacing: -0.01em; }
p { line-height: 1.6; color: var(--text-secondary); margin: 0 0 1em; }
.tabular { font-variant-numeric: tabular-nums; }

svg.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.logo-mark { height: 34px; width: auto; display: block; }

/* ---------- Auth (login) ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--white);
}
.auth-visual {
  position: relative;
  background: linear-gradient(170deg, var(--ink-800) 0%, var(--ink-900) 68%, #081a20 100%);
  color: #eaf3f0;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-visual::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 140px;
  background-image: var(--tide-lines);
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 240px 90px;
  opacity: 0.9;
  pointer-events: none;
  animation: tide-drift 46s linear infinite;
}
.auth-visual .brand { position: relative; z-index: 1; display: flex; align-items: center; }
.auth-visual .pitch { position: relative; z-index: 1; max-width: 380px; }
.auth-visual .pitch h1 { color: #fff; font-size: 2.3rem; line-height: 1.15; }
.auth-visual .pitch p { color: #b9d2ce; }
.auth-visual .stat-row { display: flex; position: relative; z-index: 1; }
.auth-visual .stat-row div { padding: 0 22px; border-left: 1px solid rgba(255,255,255,0.16); }
.auth-visual .stat-row div:first-child { padding-left: 0; border-left: none; }
.auth-visual .stat-row div strong { display: block; font-family: var(--font-display); font-size: 1.5rem; color: #fff; }
.auth-visual .stat-row div span { font-size: 0.72rem; color: #9fc2bc; text-transform: uppercase; letter-spacing: 0.07em; }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 360px; animation: fade-up 0.4s ease both; }
.auth-card .eyebrow { font-size: 0.8rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 6px; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; background: var(--page-bg); }
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 14px 12px; }
.sidebar nav .nav-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--text-tertiary);
  padding: 16px 10px 5px;
}
.sidebar nav .nav-label:first-child { padding-top: 6px; }
.sidebar nav a {
  position: relative;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar nav a svg.icon { width: 17px; height: 17px; color: var(--text-tertiary); transition: color 0.15s ease; }
.sidebar nav a:hover { background: var(--surface-tertiary); color: var(--ink-900); }
.sidebar nav a:hover svg.icon { color: var(--text-secondary); }
.sidebar nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar nav a.active::before { content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 2.5px; border-radius: 0 3px 3px 0; background: var(--brand); }
.sidebar nav a.active svg.icon { color: var(--brand); stroke: var(--brand); }
.nav-count { margin-left: auto; background: var(--coral-500); color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 1; padding: 3px 7px; border-radius: 999px; }
/* Filigrana di marea in fondo alla sidebar: la firma dell'app, sottovoce */
.sidebar::after {
  content: '';
  height: 66px;
  flex-shrink: 0;
  background-image: var(--tide-lines-ink);
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 240px 90px;
  pointer-events: none;
}
.sidebar .user-box { border-top: 1px solid var(--border); padding: 14px; font-size: 0.85rem; }
.sidebar .user-box .who { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.sidebar .user-box .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 0.78rem; flex-shrink: 0; }
.sidebar .user-box .name { color: var(--ink-800); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user-box .logout { color: var(--text-secondary); display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.sidebar .user-box .logout:hover { color: var(--danger-500); }

.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

.main { flex: 1; min-width: 0; }
.topheader {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 28px;
}
.notif-wrap { position: relative; }
.topheader .bell {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.topheader .bell:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft-2); }
.notif-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral-500); border: 2px solid var(--surface); }
.notif-dropdown {
  display: none;
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 70;
}
.notif-dropdown.open { display: block; animation: modal-in 0.15s ease; }
.notif-dropdown-head { padding: 14px 18px; font-weight: 700; font-family: var(--font-display); color: var(--ink-800); border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.notif-list { display: flex; flex-direction: column; }
.notif-item, .notif-empty { display: flex; flex-direction: column; gap: 3px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--page-bg); }
.notif-item.unread { background: var(--brand-soft); }
.notif-item.unread:hover { background: var(--brand-soft-2); }
.notif-msg { color: var(--text-primary); line-height: 1.4; }
.notif-time { color: var(--text-tertiary); font-size: 0.76rem; }
.notif-empty { color: var(--text-secondary); text-align: center; }
@media (max-width: 860px) { .notif-dropdown { width: 92vw; right: -8px; } }
.topheader .profile { display: flex; align-items: center; gap: 10px; background: none; border: none; padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font); transition: background 0.15s ease; }
.topheader .profile:hover { background: var(--surface-tertiary); }
.topheader .profile .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 0.75rem; flex-shrink: 0; }
.topheader .profile .name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.topheader .profile .chevron { width: 14px; height: 14px; color: var(--text-tertiary); transition: transform 0.15s ease; }
.topheader .profile.open .chevron { transform: rotate(180deg); }
.profile-dropdown { width: 180px; padding: 6px; }
.profile-dropdown .notif-item { flex-direction: row; align-items: center; gap: 9px; border-bottom: none; border-radius: var(--radius-sm); font-weight: 600; color: var(--text-primary); }
.profile-dropdown .notif-item:hover { background: var(--coral-soft); color: var(--coral-500); }
.profile-dropdown .notif-item svg.icon { width: 16px; height: 16px; color: inherit; }

/* Ricerca globale (Cmd/Ctrl+K) */
.global-search-trigger {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 10px; color: var(--text-tertiary); font-size: 0.83rem; font-family: var(--font);
  cursor: pointer; margin-right: auto; transition: border-color 0.15s ease, color 0.15s ease;
}
.global-search-trigger svg.icon { width: 15px; height: 15px; }
.global-search-trigger:hover { border-color: var(--brand-soft-2); color: var(--text-secondary); }
.global-search-trigger .kbd-hint { margin-left: 6px; }
.kbd-hint { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 0.72rem; color: var(--text-tertiary); }
.global-search-overlay {
  display: none; position: fixed; inset: 0; background: rgba(22, 20, 16, 0.45); z-index: 200;
  align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.global-search-overlay.open { display: flex; animation: modal-in 0.12s ease; }
.global-search-box {
  width: 560px; max-width: 92vw; max-height: 60vh; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.global-search-input-row { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.global-search-input-row svg.icon { width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0; }
.global-search-input-row input { flex: 1; border: none; outline: none; font-size: 0.98rem; font-family: var(--font); background: transparent; color: var(--text-primary); }
.global-search-results { overflow-y: auto; padding: 6px; }
.global-search-group-label { padding: 10px 12px 4px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-tertiary); }
.global-search-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: var(--radius-sm); }
.global-search-item:hover { background: var(--brand-soft); }
.global-search-item-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.global-search-item-subtitle { font-size: 0.78rem; color: var(--text-tertiary); }
@media (max-width: 700px) { .global-search-trigger span:not(.kbd-hint) { display: none; } .global-search-trigger .kbd-hint { display: none; } }

.main-inner { padding: 30px 36px 60px; max-width: 1240px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 14px; }
.topbar .subtitle { color: var(--text-secondary); font-size: 0.95rem; margin-top: 2px; }
.hero-banner {
  position: relative;
  overflow: hidden;
  background: linear-gradient(170deg, var(--ink-800) 0%, var(--ink-900) 70%, #081a20 100%);
  border-radius: var(--radius-lg);
  padding: 26px 32px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}
.hero-banner::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 90px;
  background-image: var(--tide-lines);
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 240px 90px;
  pointer-events: none;
  animation: tide-drift 46s linear infinite;
}
.hero-text { position: relative; z-index: 1; }
.hero-text h1 { color: #fff; margin-bottom: 6px; font-size: 1.7rem; }
.hero-text p { color: #b9d2ce; margin-bottom: 16px; max-width: 420px; }
.btn-hero { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.btn-hero:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }
.hero-stats { position: relative; z-index: 1; display: flex; flex-shrink: 0; }
.hero-stat { padding: 0 22px; text-align: left; border-left: 1px solid rgba(255,255,255,0.16); }
.hero-stat:first-child { padding-left: 0; border-left: none; }
.hero-stat strong { display: block; font-family: var(--font-display); font-size: 1.6rem; color: #fff; }
.hero-stat span { font-size: 0.7rem; color: #9fc2bc; text-transform: uppercase; letter-spacing: 0.07em; }
@media (max-width: 860px) {
  .hero-banner { flex-direction: column; align-items: flex-start; padding: 24px 22px; }
  .hero-stats { flex-wrap: wrap; row-gap: 12px; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--ink-800);
    cursor: pointer;
  }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(12,34,41,0.4); z-index: 55; }
  .main-inner { padding: 18px 18px 40px; }
  .topheader { padding: 0 14px; justify-content: space-between; gap: 10px; }
  .topheader .name, .topheader .bell { display: none; }
}

/* ---------- Componenti ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 22px;
}
.layout-with-rail { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.layout-rail { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 1000px) { .layout-with-rail { grid-template-columns: 1fr; } }
.rail-list { display: flex; flex-direction: column; gap: 4px; }
.rail-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 8px; border-radius: var(--radius-sm); transition: background 0.12s ease; }
.rail-item:hover { background: var(--page-bg); }
.rail-item-title { font-size: 0.87rem; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid { display: grid; gap: 18px; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { min-width: 0; }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 480px; }
@media (max-width: 900px) {
  .grid-cols-4, .grid-cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

.stat-card { display: flex; flex-direction: column; gap: 10px; }
.stat-card .stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat-card .label { font-size: 0.72rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; line-height: 1.35; padding-top: 5px; }
.stat-card .icon-badge { width: 28px; height: 28px; border-radius: 8px; background: transparent !important; color: var(--text-tertiary) !important; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: var(--ink-900); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-card .stat-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-card .delta { font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.stat-card .delta.up { color: var(--success-500); }
.stat-card .delta.down { color: var(--coral-500); }
.stat-card .sparkline { flex-shrink: 0; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success-500); position: relative; flex-shrink: 0; }
.live-dot::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 1.5px solid var(--success-500); opacity: 0.6;
  animation: pulse-ring 2.2s cubic-bezier(0.2,0.6,0.4,1) infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.7; }
  80% { transform: scale(1.8); opacity: 0; }
  100% { opacity: 0; }
}

.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.avatar-row { display: flex; align-items: center; gap: 10px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.badge-green { background: var(--success-soft); color: var(--success-600); }
.badge-cream { background: var(--brand-soft); color: var(--brand); }
.badge-amber { background: #fbeed7; color: #a5701e; }
.badge-red { background: var(--coral-soft); color: var(--coral-500); }
.badge-gray { background: var(--surface-tertiary); color: var(--text-secondary); }

.status-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 0.84rem; font-weight: 600; color: var(--text-primary); }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-dot.dot-green { color: var(--success-600); }
.status-dot.dot-amber { color: #a5701e; }
.status-dot.dot-red { color: var(--danger-500); }
.status-dot.dot-brand { color: var(--brand); }
.status-dot.dot-gray { color: var(--text-secondary); }

.priority-rail { border-left: 3px solid var(--border); padding-left: 18px; }
.priority-rail.priority-alta { border-left-color: var(--coral-500); }
.priority-rail.priority-normale { border-left-color: var(--brand); }
.priority-rail.priority-bassa { border-left-color: var(--border); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--white); color: var(--ink-800); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-tertiary); border-color: #d8d8d4; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-tertiary); color: var(--ink-800); }
.btn-sm { padding: 7px 13px; font-size: 0.82rem; }
.btn-danger-text { color: var(--danger-500); }
.btn-block { width: 100%; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5d5d5; border-radius: 99px; border: 2px solid var(--page-bg); }
::-webkit-scrollbar-thumb:hover { background: #b9b9b9; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-800); margin-bottom: 6px; }

/* Base condivisa per tutti i controlli di form, dentro o fuori da .field */
select, textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], input[type="search"], input[type="tel"], input[type="url"] {
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-family: var(--font);
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select:hover, textarea:hover,
input[type="text"]:hover, input[type="email"]:hover, input[type="password"]:hover,
input[type="date"]:hover, input[type="number"]:hover, input[type="search"]:hover, input[type="tel"]:hover, input[type="url"]:hover {
  border-color: #cdd5d5;
}
select:focus, textarea:focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="date"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="url"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 100px; }
::placeholder { color: var(--text-tertiary); opacity: 1; }

/* Select custom: niente freccia di sistema, freccetta disegnata coerente col brand */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-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 1l5 5 5-5' fill='none' stroke='%2397a4a8' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}
select:disabled {
  background-color: var(--surface-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.75;
}

/* Upload file: il bottone nativo "Scegli file" reskin coerente coi bottoni dell'app */
input[type="file"] {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-tertiary);
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input[type="file"]:hover { border-color: var(--brand); background: var(--brand-soft); }
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover { background: var(--brand-hover); }

.search-input { position: relative; max-width: 300px; }
.search-input svg.icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.search-input input { padding-left: 36px; border-color: var(--brand); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; font-size: 0.88rem; border-bottom: 1px solid var(--border-soft); }
th { color: var(--text-tertiary); font-weight: 600; font-size: 0.71rem; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-tertiary); }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.alert-error { background: var(--danger-soft); color: var(--danger-500); }
.alert-success { background: var(--success-soft); color: var(--success-600); }

.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink-800); color: #fff; padding: 13px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 0.88rem; display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.25s ease, toast-out 0.3s ease 3.2s forwards;
}
.toast.toast-success { background: var(--success-600); }
.toast.toast-error { background: var(--danger-500); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

.empty-state { text-align: center; padding: 52px 20px; color: var(--text-secondary); }
.empty-state .icon-wrap { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }

.site-tabs { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.site-tabs a { padding: 7px 14px; border-radius: var(--radius); font-size: 0.85rem; font-weight: 600; background: var(--white); color: var(--text-secondary); border: 1px solid var(--border); transition: all 0.15s ease; }
.site-tabs a:hover { border-color: var(--text-tertiary); color: var(--ink-800); }
.site-tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.period-tabs { display: inline-flex; background: var(--surface-tertiary); border-radius: 999px; padding: 3px; gap: 2px; }
.period-tabs a { padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); }
.period-tabs a.active { background: var(--white); color: var(--ink-800); box-shadow: var(--shadow-sm); }

.modal-overlay { position: fixed; inset: 0; background: rgba(12,34,41,0.5); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-overlay.open { display: flex; animation: fade-in 0.15s ease; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 28px 28px;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
  box-sizing: border-box;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; position: sticky; top: -24px; background: #fff; padding-top: 24px; margin-top: -24px; z-index: 1; }
.modal-head h3 { display: flex; align-items: center; gap: 9px; margin-bottom: 0; }
.modal-head h3 svg.icon { color: var(--brand); flex-shrink: 0; }
.modal-close { background: var(--surface-tertiary); border: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; }
.modal-close svg.icon { width: 14px; height: 14px; }
.modal-close:hover { background: var(--coral-soft); color: var(--coral-500); }
.modal .flex.gap-8 { flex-wrap: wrap; }

/* Le griglie a 2/3 colonne dentro le modali restano leggibili solo su schermi
   larghi: la modale ha comunque un max-width fisso, quindi su tablet e mobile
   colonne strette sono illeggibili — meglio impilare i campi. */
@media (max-width: 900px) {
  .modal .grid-cols-2, .modal .grid-cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 20px 18px 22px; animation: modal-in-sheet 0.2s ease; }
  .modal-head { top: -20px; padding-top: 20px; margin-top: -20px; }
}
@keyframes modal-in-sheet { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
@media (max-width: 700px) { .health-grid { grid-template-columns: 1fr; } }
.health-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); background: var(--page-bg); border: 1px solid var(--border); }
.health-item strong { display: block; font-size: 0.88rem; color: var(--ink-800); margin-bottom: 2px; }
.health-item p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.health-item p a { color: var(--brand); font-weight: 600; }
.health-item p a:hover { text-decoration: underline; }
.health-item.health-warn { border-color: #f0d5a8; }
.health-item.health-danger { border-color: #eabdbd; }

.uptime-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700; }
.uptime-pill .uptime-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success-500); }
.uptime-pill.up { color: var(--success-600); }
.uptime-pill.down .uptime-dot { background: var(--danger-500); }
.uptime-pill.down { color: var(--danger-500); }
.expiry-line { font-size: 0.78rem; color: var(--text-secondary); }
.expiry-line.soon { color: #a5701e; font-weight: 700; }
.expiry-line.expired { color: var(--danger-500); font-weight: 700; }

.comment-thread { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 12px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1; background: var(--page-bg); border-radius: var(--radius-sm); padding: 9px 13px; }
.comment.comment-admin .comment-body { background: var(--brand-soft); }
.comment-meta { display: flex; align-items: baseline; gap: 8px; font-size: 0.78rem; margin-bottom: 2px; }
.comment-meta strong { color: var(--ink-800); font-size: 0.83rem; }
.comment-body p { margin: 0; color: var(--text-primary); font-size: 0.88rem; line-height: 1.5; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.86rem; resize: vertical; min-height: 38px; }
.comment-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.comment-system { text-align: center; font-size: 0.78rem; color: var(--text-tertiary); padding: 2px 0; }

.text-muted { color: var(--text-secondary); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-24 { margin-top: 24px; }
