:root {
  /* Palette Workland */
  --wl-orange:   #F39200;
  --wl-magenta:  #E90081;
  --wl-blue:     #00A2E7;
  --wl-bordeaux: #A4333F;

  /* Varianti leggibili come testo su sfondo chiaro (contrasto AA) */
  --wl-blue-ink:    #0277a8;
  --wl-magenta-ink: #b80067;

  /* Neutri / superfici */
  --bg:      #f4f6f8;
  --surface: #ffffff;
  --line:    #e4e7ec;
  --text:    #1f2937;
  --muted:   #6b7280;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --gradient: linear-gradient(90deg, var(--wl-orange) 0%, var(--wl-magenta) 45%, var(--wl-blue) 100%);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--wl-blue-ink); }
a:hover { color: var(--wl-blue); }

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

/* Barra accento con i colori del brand */
.brandbar { height: 4px; background: var(--gradient); }

/* ---- Login ---- */
.card.login {
  max-width: 380px;
  margin: 9vh auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.card.login .logo { width: 64px; height: 64px; margin: 0 auto 0.75rem; display: block; }
.card.login h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.01em; }
.card.login .sub { margin: 0.25rem 0 1.5rem; color: var(--muted); }
.card.login form { text-align: left; }
.card.login label { display: block; margin: 0.75rem 0 0.3rem; font-size: 0.88rem; font-weight: 600; }
.card.login input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.card.login input:focus { border-color: var(--wl-blue); }
.card.login button[type="submit"] { width: 100%; margin-top: 1.25rem; }
.errore {
  background: #fdecef;
  color: var(--bordeaux, var(--wl-bordeaux));
  border: 1px solid #f6cdd3;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .brand { display: flex; align-items: center; gap: 0.7rem; }
.topbar .logo { width: 34px; height: 34px; display: block; }
.topbar strong { font-size: 1.05rem; letter-spacing: -0.01em; }
.topbar .brand .muted { font-weight: 400; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }

/* ---- Stats ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--wl-blue);
}
.stat.accent::before { background: var(--wl-magenta); }
.stat-label { font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value { font-size: 1.15rem; font-weight: 600; }
.stat-value.big { font-size: 2rem; color: var(--wl-magenta-ink); line-height: 1.1; }

/* ---- Azioni ---- */
.azioni {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

/* Pulsante primario: pieno arancione, testo scuro (contrasto AA) */
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--wl-orange);
  color: #3d2600;
  font-weight: 700;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  transition: filter 0.12s ease, background 0.12s ease;
}
button:hover, .btn:hover { filter: brightness(0.94); }

/* Pulsante secondario (download CSV): contorno blu */
.btn {
  background: #fff;
  color: var(--wl-blue-ink);
  border-color: var(--line);
  font-weight: 600;
}
.btn:hover { border-color: var(--wl-blue); background: #f0fafe; filter: none; }

button:disabled { opacity: 0.55; cursor: default; filter: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--wl-blue);
  outline-offset: 2px;
}

/* Link-button (logout): bordeaux */
button.link {
  background: none;
  border: none;
  color: var(--wl-bordeaux);
  padding: 0.3rem 0.2rem;
  font-weight: 600;
}
button.link:hover { filter: none; text-decoration: underline; }

/* ---- Tabella ---- */
.tabella-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); }
thead th { color: var(--muted); font-weight: 600; background: #fafbfc; text-transform: uppercase; font-size: 0.74rem; letter-spacing: 0.03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(243, 146, 0, 0.06); }

.badge.pending {
  background: #fde4f1;
  color: var(--wl-magenta-ink);
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok {
  background: #e6f0ea;
  color: #1f7a4d;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pager { display: flex; gap: 1rem; margin-top: 1.1rem; align-items: center; }
.pager a { font-weight: 600; text-decoration: none; }
.pager .disabled { color: var(--muted); }

/* ---- Filtro stato ---- */
.filtro { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.chip {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}
.chip:hover { border-color: var(--wl-blue); color: var(--wl-blue-ink); }
.chip.on { background: var(--wl-blue-ink); color: #fff; border-color: var(--wl-blue-ink); }

/* ---- Colonna URL ---- */
td.url a {
  display: inline-block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ---- Azione "Cambia stato" in tabella ---- */
tbody form { margin: 0; }
tbody button.link { color: var(--wl-blue-ink); font-size: 0.85rem; font-weight: 600; }

/* ---- Inizializza (azione distruttiva) ---- */
.inline-form { display: inline; margin: 0; }
.btn-danger { background: var(--wl-bordeaux); color: #fff; border-color: var(--wl-bordeaux); }
.btn-danger:hover { filter: brightness(0.92); }
.hint { margin-top: -1rem; margin-bottom: 1.5rem; font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
