/* AVS Studio — area personale. Stile minimal/premium coerente col sito pubblico. */

:root {
  --ink: #14151a;
  --ink-soft: #3a3d47;
  --muted: #6b6f7a;
  --line: #e7e8ec;
  --bg: #ffffff;
  --bg-alt: #f7f7f8;
  --accent: #b0843a;
  --accent-strong: #946d2c;
  --accent-tint: #f4ecdd;
  --ok: #2f7d4f;
  --ok-tint: #e6f2ea;
  --err: #b3261e;
  --err-tint: #f7e7e6;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 21, 26, .04), 0 4px 18px rgba(20, 21, 26, .05);
  --shadow-md: 0 8px 40px rgba(20, 21, 26, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: var(--accent-strong); }

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}
.wrap-narrow { max-width: 760px; }

/* ---------- Top nav ---------- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .85);
  color: var(--ink);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink);
}
.app-brand .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
}
.app-nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: .92rem;
}
.app-nav-right .who { color: var(--muted); }
.app-nav-right a { color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.app-nav-right a:hover { color: var(--ink); }
.app-nav-right form { margin: 0; }

/* ---------- Layout ---------- */
.app-main { padding: 40px 0 64px; background: var(--bg-alt); }

.page-head { margin-bottom: 26px; }
.page-head .kicker {
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.page-head h1 {
  margin: 6px 0 0;
  font-size: 1.9rem;
  letter-spacing: -.02em;
}
.page-head p { margin: 6px 0 0; color: var(--muted); }
.back-link {
  display: inline-block;
  margin-bottom: 18px;
  font-size: .9rem;
  color: var(--muted);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 26px 28px;
  margin-bottom: 20px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: -.01em;
}
.card .card-sub { margin: 0 0 18px; color: var(--muted); font-size: .92rem; }
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Dashboard nav cards ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.nav-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .14s ease, box-shadow .14s ease;
}
.nav-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.nav-card .ico {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px;
  background: var(--accent-tint);
  color: var(--accent-strong);
}
.nav-card .ico svg { width: 22px; height: 22px; }
.nav-card h3 { margin: 2px 0 4px; font-size: 1.08rem; letter-spacing: -.01em; }
.nav-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.nav-card.disabled { opacity: .55; pointer-events: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: var(--err-tint); color: var(--err); border-color: #e9c9c6; }
.btn-danger:hover { background: #f0d6d4; }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-spaced { margin-bottom: 10px; }
.btn-top-gap { margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 180px; }
.inline-admin-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 10px;
  vertical-align: middle;
}
.inline-admin-form select {
  width: auto;
  min-width: 116px;
  padding: 6px 28px 6px 10px;
  font-size: .84rem;
  border-radius: 8px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  color: var(--ink-soft);
  font-size: .92rem;
}
.check-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.field-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  font-size: .88rem;
  color: var(--ink-soft);
  line-height: 1.45;
  text-align: left;
}
.field-checkbox input[type=checkbox] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
  margin-top: 2px;
  cursor: pointer;
}
.field-checkbox label {
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.field-checkbox label a {
  color: var(--accent-strong);
  text-decoration: underline;
}
.field-checkbox label a:hover {
  color: var(--accent);
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: 10px;
  padding: 12px 15px;
  font-size: .9rem;
  margin-bottom: 18px;
  border: 1px solid;
}
.alert-error { background: var(--err-tint); border-color: #e9c9c6; color: var(--err); }
.alert-success { background: var(--ok-tint); border-color: #cfe5d6; color: var(--ok); }
.alert-info { background: var(--accent-tint); border-color: #e7d6b8; color: var(--accent-strong); }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th, .data-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.data-table thead th {
  font-size: .76rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.data-table tbody tr:hover { background: var(--bg-alt); }
.data-table .right { text-align: right; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
}
.badge-owner { background: var(--accent-tint); color: var(--accent-strong); }
.badge-member { background: var(--bg-alt); color: var(--muted); }
.badge-admin { background: var(--ink); color: #fff; }
.badge-on { background: var(--ok-tint); color: var(--ok); }
.badge-off { background: var(--err-tint); color: var(--err); }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: calc(100vh - 68px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 36px 34px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -.02em; }
.auth-card .sub { margin: 0 0 24px; color: var(--muted); font-size: .92rem; }
.auth-foot { margin-top: 20px; font-size: .88rem; color: var(--muted); text-align: center; }

/* ---------- Lavagna ---------- */
.lavagna-list { list-style: none; margin: 0; padding: 0; }
.lavagna-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}
.lavagna-list li:last-child { border-bottom: none; }
.lavagna-list input[type=checkbox] {
  width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer;
}
.lavagna-list .txt { flex: 1; }
.lavagna-list .done .txt { color: var(--muted); text-decoration: line-through; }

/* ---------- Detail sections (moduli) ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.detail-grid .full { grid-column: 1 / -1; }
.kv { display: flex; flex-direction: column; gap: 8px; }
.kv .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: .92rem;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
}
.kv .row:last-child { border-bottom: none; padding-bottom: 0; }
.kv .row .k { color: var(--muted); }
.kv .row .v { font-weight: 500; text-align: right; }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-list a {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: .9rem;
}
.attach-list a:hover { border-color: var(--accent); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 1.1rem; }

/* ---------- Construction page ---------- */
.construction {
  min-height: calc(100vh - 68px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}
.construction .inner { max-width: 480px; }
.construction .mark {
  width: 56px; height: 56px; margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px; background: var(--accent-tint); color: var(--accent-strong);
}
.construction h1 { margin: 0 0 10px; font-size: 1.7rem; letter-spacing: -.02em; }
.construction p { margin: 0 0 8px; color: var(--muted); }

/* ---------- Trial banner ---------- */
.trial-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 24px;
  font-size: .94rem;
  border: 1px solid;
}
.trial-banner .tb-ico {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.trial-banner .tb-ico svg { width: 20px; height: 20px; }
.trial-banner.is-active {
  background: var(--accent-tint);
  border-color: #e7d6b8;
  color: var(--accent-strong);
}
.trial-banner.is-active .tb-ico { background: #e7d6b8; }
.trial-banner.is-expired {
  background: var(--err-tint);
  border-color: #e9c9c6;
  color: var(--err);
}
.trial-banner.is-expired .tb-ico { background: #e9c9c6; }

/* ---------- Member banner ---------- */
.member-banner {
  background: var(--accent-tint);
  border: 1px solid #e7d6b8;
  color: var(--accent-strong);
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 20px;
  font-size: .94rem;
}
.member-banner a { font-weight: 600; }

/* ---------- Light button (su sfondo scuro) ---------- */
.btn-light { background: #fff; color: var(--ink); }
.btn-light:hover { background: #ececec; }

/* ---------- Piani / price card ---------- */
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.price-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.price-card.featured {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}
.price-card.current { border-color: var(--accent); }
.price-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 4px 11px;
  margin-bottom: 14px;
}
.price-card.featured .price-tag { color: var(--ink); background: #d8b15e; }
.price-card h3 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.price-card.compact { gap: 12px; }
.price-card.compact .price-amount .num { font-size: 2rem; }
.storage-plan-grid { margin-top: 16px; }
.price-card .blurb {
  margin: 8px 0 18px;
  font-size: .9rem;
  color: var(--muted);
  min-height: 58px;
}
.price-card.featured .blurb { color: #b6b8c2; }
.price-amount { display: flex; align-items: baseline; gap: 6px; }
.price-amount .num { font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em; }
.price-amount .per { color: var(--muted); font-size: .9rem; }
.price-card.featured .price-amount .per { color: #b6b8c2; }
.price-second { margin: 6px 0 0; font-size: .88rem; color: var(--muted); }
.price-card.featured .price-second { color: #b6b8c2; }
.price-list {
  list-style: none;
  margin: 20px 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.price-card.featured .price-list { border-color: rgba(255, 255, 255, .14); }
.price-list li { display: flex; align-items: flex-start; gap: 9px; font-size: .9rem; }
.price-list li svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}
.price-card.featured .price-list li svg { color: #d8b15e; }
.price-cta { margin-top: auto; }
.price-current-label {
  margin-top: auto;
  text-align: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  padding-top: 8px;
}

/* ---------- Plan info row (dashboard owner) ---------- */
.plan-info { display: flex; align-items: center; gap: 14px; }
.plan-info .pi-ico {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--accent-tint);
  color: var(--accent-strong);
}
.plan-info .pi-ico svg { width: 21px; height: 21px; }
.plan-info .pi-text h3 { margin: 0; font-size: 1.02rem; }
.plan-info .pi-text p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Pagina admin ---------- */
.card-row h2 { margin: 0; }

.admin-reset-link {
  word-break: break-all;
}

.admin-limit-field {
  flex: 0 0 260px;
}

.admin-note {
  font-size: .85rem;
  margin-top: 8px;
}

.admin-search {
  width: auto;
  min-width: 220px;
  max-width: 320px;
  padding: 9px 12px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.admin-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.admin-create {
  margin: 14px 0 8px;
  padding: 12px 0 2px;
  border-top: 1px solid var(--line);
}
.admin-create summary {
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent-strong);
}
.admin-create summary:hover { color: var(--ink); }
.admin-create-form { margin-top: 14px; }
.admin-create-email { min-width: 220px; }
.admin-create-name { min-width: 170px; }
.admin-create-plan { flex: 0 0 150px; }

.cell-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.cell-form select,
.cell-form input[type=date],
.cell-form input[type=number] {
  width: auto;
  padding: 6px 10px;
  font-size: .84rem;
  border-radius: 8px;
}
.cell-form input[type=number] { width: 6rem; }

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.admin-actions form { margin: 0; }

.admin-team-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  text-align: right;
}

.admin-team-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  list-style: none;
  cursor: pointer;
}
.admin-team-summary::-webkit-details-marker { display: none; }
.admin-team-summary-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.admin-team-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.admin-team-summary .card-sub {
  margin: 0;
}
.admin-team-summary-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-team-toggle {
  min-width: 82px;
}
.admin-team-toggle-open,
.admin-team[open] .admin-team-toggle-closed {
  display: none;
}
.admin-team[open] .admin-team-toggle-open {
  display: inline;
}
.admin-team-body {
  margin-top: 18px;
}
details.admin-team > .card-row,
details.admin-team > p.card-sub {
  display: none;
}

.admin-team-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 12px 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-alt);
}
.admin-team-grid form { margin: 0; }
.admin-quota-field { flex: 0 0 150px; }
.admin-member-limit-field { flex: 0 0 170px; }
.admin-add-member-field {
  min-width: 300px;
}
.admin-team-foot { margin-top: 14px; }
.admin-team-foot form { margin: 0; }

.table-scroll { overflow-x: auto; }

/* ---------- Admin stats ---------- */
.stats-section { margin: 28px 0; }
.stats-section h2 { margin-bottom: 12px; }
.stats-sectionnav a {
  text-decoration: none;
  padding: 4px 10px;
  background: #f4f5f7;
  border-radius: 14px;
}
.stats-sectionnav a:hover { background: #e6e8ec; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.kpi {
  padding: 14px;
  background: #fff;
  border: 1px solid #e6e8ec;
  border-radius: 10px;
}
.kpi.kpi-warn { border-color: #f5b78a; background: #fff8f1; }
.kpi-grid-delivery { margin-top: 12px; }
.kpi-grid-delivery .kpi-value { font-size: 20px; }
.kpi-label {
  font-size: 12px;
  opacity: .7;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stats-subhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin: 24px 0 10px;
}
.stats-subhead h3 { margin: 0; }
.stats-alert {
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  background: #f7f8fa;
  color: #394150;
  font-size: 13px;
  font-weight: 600;
}
.stats-alert-ok {
  border-color: #cfe8d5;
  background: #f2fbf4;
  color: #28633b;
}
.stats-alert-warn {
  border-color: #f5b78a;
  background: #fff8f1;
  color: #9a4c16;
}
.stats-alert-danger {
  border-color: #ef9a9a;
  background: #fff4f4;
  color: #a02b2b;
}
.grid-2 {
  display: grid;
  /* minmax(0,1fr): senza il minimo esplicito una tabella larga (es. "Top
     cataloghi") allarga la propria colonna e i due pannelli si sbilanciano. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.grid-2 > .card { min-width: 0; }
.big-numbers {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.big-numbers > div { flex: 1 1 100px; }
.bn-label { font-size: 12px; opacity: .7; }
.bn-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th,
.stats-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
}
.table-wrap { max-height: 260px; overflow: auto; }
.heatmap {
  display: grid;
  /* minmax(0,1fr): con 1fr puro le etichette orarie impongono una larghezza
     minima per colonna e su card strette la griglia sborda dal pannello. */
  grid-template-columns: auto repeat(24, minmax(0, 1fr));
  gap: 2px;
  font-size: 10px;
  min-width: 0;
}
.heatmap .hcell { background: #eef0f3; min-height: 14px; border-radius: 2px; }
.heatmap .hlabel {
  padding: 1px 2px;
  opacity: .7;
  font-size: 10px;
  align-self: center;
  overflow: hidden;
  white-space: nowrap;
}

/* "i" di info accanto al titolo di ogni pannello statistiche: il testo in
   data-info appare come tooltip su hover/focus (tastiera inclusa). */
.info-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: #e6e8ec;
  color: #4b5563;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
  user-select: none;
}
.info-dot:hover,
.info-dot:focus {
  background: #4c8bf5;
  color: #fff;
  outline: none;
}
.info-dot::after {
  content: attr(data-info);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: 300px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #1f232b;
  color: #f4f5f7;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease;
}
.info-dot:hover::after,
.info-dot:focus::after { opacity: 1; visibility: visible; }
/* Nei pannelli della colonna destra il tooltip non deve uscire dallo schermo. */
.info-dot.info-right::after {
  left: auto;
  right: -8px;
  transform: none;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats-subhead { align-items: stretch; flex-direction: column; }
  .stats-alert { max-width: none; }
}

/* ---------- Footer ---------- */
.app-foot {
  border-top: 1px solid var(--line);
  padding: 26px 0;
  font-size: .85rem;
  color: var(--muted);
}
.app-foot .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.app-foot a { color: var(--muted); text-decoration: none; margin-left: 16px; }
.app-foot a:hover { color: var(--ink); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.stack > * + * { margin-top: 14px; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 22px 0; }

@media (max-width: 760px) {
  .grid-cards, .detail-grid, .price-grid { grid-template-columns: 1fr; }
  .app-nav-right { gap: 12px; }
  .admin-search,
  .admin-limit-field,
  .admin-create-email,
  .admin-create-name,
  .admin-create-plan,
  .admin-quota-field,
  .admin-member-limit-field,
  .admin-add-member-field {
    width: 100%;
    min-width: 0;
    flex-basis: 100%;
  }
  .admin-team-meta {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }
  .admin-team-summary,
  .admin-team-summary-side {
    align-items: flex-start;
    justify-content: flex-start;
  }
  .admin-team-summary {
    flex-direction: column;
  }
  .cell-form {
    display: flex;
  }
}

/* ---------- Moduli Card Layout & Premium styles ---------- */
.moduli-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 10px;
}

@media (max-width: 480px) {
  .moduli-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.modulo-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 5px solid var(--muted);
  text-decoration: none;
  color: inherit;
  outline: none;
}

.modulo-card:hover, .modulo-card:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.modulo-card.modulo-contratto {
  border-left-color: var(--accent);
}

.modulo-card.modulo-preventivo {
  border-left-color: var(--muted);
}

.modulo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modulo-card-code {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  font-family: monospace;
}

.modulo-card-cliente {
  margin: 2px 0 4px;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}

.modulo-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: .84rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

@media (max-width: 360px) {
  .modulo-card-body {
    grid-template-columns: 1fr;
  }
}

.modulo-card-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.modulo-card-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modulo-card-info svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.8;
}

.modulo-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.badge-contratto {
  background: var(--accent-tint);
  color: var(--accent-strong);
}

.badge-preventivo {
  background: var(--bg-alt);
  color: var(--muted);
}

.badge-stato {
  background: var(--bg-alt);
  color: var(--ink-soft);
  font-weight: 600;
  border-radius: 6px;
  font-size: .74rem;
}

/* Tool bar adjustments & Sort Button */
.moduli-toolbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .inline-form .field {
    min-width: 0 !important;
  }
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sort-btn:hover {
  border-color: var(--ink);
  background: var(--bg-alt);
  transform: translateY(-1px);
}

.sort-btn.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(20, 21, 26, 0.15);
}

body.is-busy {
  pointer-events: none;
  opacity: .75;
  cursor: wait;
}

.stepup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 21, 26, .45);
}
.stepup-modal[hidden] { display: none; }
.stepup-modal-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 28px;
  width: 100%;
  max-width: 380px;
}
.stepup-modal-card h2 { margin: 0 0 4px; font-size: 1.15rem; }

.stats-card-head,
.stats-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.stats-card-head h3,
.stats-modal-head h2 { margin: 0; }
.stats-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 21, 26, .45);
}
.stats-modal[hidden] { display: none; }
.stats-modal-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  width: min(980px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: hidden;
}
.stats-modal-table {
  margin-top: 16px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}
