/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Header --- */
header {
  background: #003366;
  color: #fff;
  padding: 1.25rem 1rem;
  text-align: center;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
.subtitle { font-size: 0.8rem; opacity: 0.85; margin-top: 0.25rem; }

/* --- Counters --- */
.counters {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.counter-box {
  flex: 0 0 auto;
  min-width: 5.5rem;
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.counter-box .num { font-size: 1.5rem; font-weight: 700; }
.counter-box .label { font-size: 0.7rem; color: #555; text-transform: uppercase; letter-spacing: 0.03em; }
.counter-box.green .num { color: #1a8a3f; }
.counter-box.orange .num { color: #c56500; }
.counter-box.red .num { color: #c53030; }
.counter-box.blue .num { color: #2563eb; }

/* --- Filters --- */
.filters {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.filter-btn {
  flex: 0 0 auto;
  padding: 0.4rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 20px;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: #003366; }
.filter-btn.active {
  background: #003366;
  color: #fff;
  border-color: #003366;
}

/* --- Card List --- */
.card-list { padding: 0.5rem 1rem 2rem; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-left: 4px solid #ccc;
}
.card.p3 { border-left-color: #c53030; }
.card.p2 { border-left-color: #c56500; }
.card.scaricato { border-left-color: #1a8a3f; }
.card.non-trovato { border-left-color: #888; opacity: 0.7; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.card-id { font-size: 0.7rem; font-weight: 600; color: #666; white-space: nowrap; }
.card-priority {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  white-space: nowrap;
}
.card-priority.p3 { background: #fee2e2; color: #991b1b; }
.card-priority.p2 { background: #fef3c7; color: #92400e; }

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.35rem;
}
.card-meta {
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 0.5rem;
}
.card-meta span { display: inline-block; margin-right: 0.75rem; }

.card-stato {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.card-actions button, .card-actions a {
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.12s;
}
.card-actions button:hover, .card-actions a:hover {
  background: #eee;
  border-color: #bbb;
}
.card-actions .btn-scaricato {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.card-actions .btn-non-trovato {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #6b7280;
}
.card-actions .btn-pdf-non-disp {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
.card-actions .btn-da-verificare {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}
.card-actions .active-status {
  font-weight: 700;
  box-shadow: inset 0 0 0 2px currentColor;
}

.card.hidden { display: none; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
  font-size: 0.9rem;
}

/* --- Footer --- */
footer {
  padding: 1rem;
  text-align: center;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.action-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}
.action-btn:hover { background: #f0f0f0; }
.action-btn.danger { color: #c53030; border-color: #c53030; }
.action-btn.danger:hover { background: #fee2e2; }
.footer-note { font-size: 0.7rem; color: #888; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: #1a1a1a;
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.8rem;
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Desktop --- */
@media (min-width: 768px) {
  header h1 { font-size: 1.5rem; }
  .counters { justify-content: center; }
  .filters { justify-content: center; }
  .card-list { max-width: 52rem; margin: 0 auto; }
  .card { padding: 1.25rem; }
  .card-title { font-size: 1.05rem; }
}
