:root {
  --primary: #00875A;
  --primary-dark: #006747;
  --danger: #DC3545;
  --warning: #FFC107;
  --info: #17A2B8;
  --success: #28A745;
  --light: #F8F9FA;
  --dark: #343A40;
  --gray: #6C757D;
  --light-gray: #E9ECEF;
  --white: #FFFFFF;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  --radius: 12px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --animation: 0.25s ease;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--light-gray);
  color: var(--dark);
  overflow-x: hidden;
  touch-action: pan-y;
}

body.no-scroll {
  overflow: hidden;
}

/* ---- App shell ---- */
.container {
  max-width: 768px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  padding-bottom: 88px; /* spazio per bottom-nav */
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.page-title {
  font-size: 18px;
  font-weight: 750;
}

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  transition: transform var(--animation), box-shadow var(--animation);
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.user-name { font-weight: 800; }
.user-sub { font-size: 13px; color: var(--gray); }

/* ---- Buttons ---- */
.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: var(--white);
  color: var(--dark);
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--animation), box-shadow var(--animation), background var(--animation), border-color var(--animation);
  font-size: 16px;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.btn.primary,
.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: transparent;
}

.btn.primary:hover,
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 14px rgba(0,135,90,0.25);
}

.btn.secondary,
.btn-secondary {
  background: var(--light);
}

.btn-danger { background: var(--danger); color: var(--white); border-color: transparent; }
.btn-warning { background: var(--warning); color: var(--dark); border-color: transparent; }

/* ---- Forms ---- */
.row {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label { font-weight: 650; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--light-gray);
  font-size: 16px;
  background: var(--white);
  transition: border-color var(--animation), box-shadow var(--animation);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,135,90,0.12);
}

.idbox {
  background: rgba(0,0,0,0.04);
  padding: 12px;
  border-radius: 12px;
  margin: 10px 0;
}

/* ---- Bottom status (compat) ---- */
.msg {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.06);
  color: var(--dark);
  border-left: 4px solid rgba(0,0,0,0.18);
  transition: opacity var(--animation);
}

.msg.ok { border-left-color: var(--success); }
.msg.error { border-left-color: var(--danger); }
.msg.info { border-left-color: var(--info); }

/* ---- Bottom navigation (Buono.html style, but hash-based) ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 12px 10px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.10);
  z-index: 1000;
  border-top: 1px solid var(--light-gray);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  color: var(--gray);
  text-decoration: none;
  flex: 1;
  max-width: 110px;
  transition: background var(--animation), transform var(--animation), color var(--animation);
}

.bottom-nav-item .icon { font-size: 20px; line-height: 1; }
.bottom-nav-item .label { font-size: 12px; font-weight: 700; }

.bottom-nav-item.active {
  color: var(--primary);
  background: rgba(0,135,90,0.10);
}

.bottom-nav-item:active { transform: scale(0.96); }

/* ---- Toggle switch (compat: existing users page) ---- */
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.user-meta { min-width: 0; }

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 64px;
  height: 32px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: 999px;
  background: #c94b4b; /* OFF */
  transition: 0.2s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.slider:before {
  content: "✕";
  position: absolute;
  height: 26px;
  width: 26px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #c94b4b;
  transition: 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.switch input:checked + .slider { background: #76b947; }
.switch input:checked + .slider:before {
  transform: translateX(32px);
  content: "✓";
  color: #76b947;
}

.chev { font-size: 26px; color: #999; user-select: none; padding-left: 4px; }

@media (min-width: 768px) {
  .container { padding: 18px; }
}

/* ---- Snackbar (toast bottom) ---- */
#toastBottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 84px;
  display: flex;
  justify-content: center;
  padding: 0 14px;
  pointer-events: none;
  z-index: 1100;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--animation), transform var(--animation);
}

#toastBottom.show {
  opacity: 1;
  transform: translateY(0);
}

.snackbar {
  pointer-events: auto;
  max-width: 560px;
  width: 100%;
  border-radius: 14px;
  padding: 12px 12px;
  background: rgba(20,20,20,0.86);
  color: var(--white);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
}

.snackbar.info { border-left: 4px solid var(--info); }
.snackbar.ok { border-left: 4px solid var(--success); }
.snackbar.error { border-left: 4px solid var(--danger); }

.snackbar__text {
  font-size: 14px;
  line-height: 1.25;
  flex: 1;
}

.snackbar__action {
  border: 0;
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}

.snackbar__action:active { transform: scale(0.98); }

/* ---- Loading overlay ---- */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1050;
}

.loading.show { display: flex; }

.loading__box {
  background: var(--white);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  width: 100%;
}

.loading__text {
  font-weight: 800;
  color: var(--dark);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.12);
  border-top-color: rgba(0,0,0,0.52);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1200;
  padding: 14px;
}

.sheet-backdrop.show { display: flex; }

.sheet {
  width: 100%;
  max-width: 720px;
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  animation: sheetUp 0.18s ease-out forwards;
  overflow: hidden;
}

@keyframes sheetUp {
  to { transform: translateY(0); }
}

.sheet__header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--light-gray);
}

.sheet__title { font-weight: 900; font-size: 15px; }

.sheet__close {
  border: 0;
  background: rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
}

.sheet__body {
  padding: 14px 16px;
  max-height: min(58vh, 520px);
  overflow: auto;
}

.sheet__actions {
  padding: 12px 16px 16px;
  display: flex;
  gap: 10px;
}

.sheet__actions .btn { width: auto; flex: 1; }

/* ---- Skeleton ---- */
.skeleton-card { border-left-color: rgba(0,0,0,0.06); }

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.12), rgba(0,0,0,0.06));
  background-size: 200% 100%;
  animation: shimmer 1.0s linear infinite;
  margin: 10px 0;
}

.skeleton-line:nth-child(1) { width: 72%; }
.skeleton-line:nth-child(2) { width: 92%; }
.skeleton-line:nth-child(3) { width: 64%; }
.skeleton-line:nth-child(4) { width: 86%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Pull-to-refresh indicator ---- */
.ptr {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -6px 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.06);
  color: var(--dark);
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--animation), transform var(--animation);
}

.ptr.show {
  opacity: 1;
  transform: translateY(0);
}
