* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #0b0b0b; font-size: 14px; }
a { color: #1976d2; }

/* Header e navigazione */
.header { background: white; border-bottom: 1px solid #e0e0e0; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 600; white-space: nowrap; }
.icon { width: 40px; height: 40px; background: linear-gradient(135deg, #2196f3, #1976d2); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px; }
.userbar { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #666; min-width: 0; }
.userbar-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { background: white; border-bottom: 1px solid #e0e0e0; padding: 0 2rem; display: flex; align-items: center; gap: 24px; overflow-x: auto; }
.nav a { padding: 12px 0; text-decoration: none; color: #999; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a.active { color: #1976d2; border-bottom-color: #2196f3; }
.nav .spacer { flex: 1; }
.nav select { padding: 6px 8px; border: 1px solid #e0e0e0; border-radius: 6px; background: white; font-size: 13px; }

.container { max-width: 1200px; margin: 2rem auto; padding: 0 2rem; }

/* Dashboard */
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.card { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 1.5rem; }
.card-label { font-size: 12px; color: #999; text-transform: uppercase; font-weight: 500; }
.card-value { font-size: 28px; font-weight: 600; margin-top: 0.5rem; }

/* Pannelli */
.panel { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.panel h2 { font-size: 18px; font-weight: 600; margin-bottom: 1rem; }
.panel h3 { font-size: 15px; font-weight: 600; margin: 1.25rem 0 0.75rem; }
.panel h3:first-child { margin-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.back { display: inline-block; margin-bottom: 1rem; text-decoration: none; font-weight: 500; }
.hint { font-size: 13px; color: #666; line-height: 1.5; }
.muted { color: #999; }
.empty { text-align: center; padding: 2rem; color: #999; }

/* Pulsanti */
.btn { background: #2196f3; color: white; border: none; border-radius: 6px; padding: 10px 16px; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-secondary { background: white; color: #1976d2; border: 1px solid #e0e0e0; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: white; color: #c62828; border: 1px solid #ef9a9a; }
.btn-whatsapp { background: #25d366; }
.link-btn { background: none; border: none; color: #1976d2; font-size: 13px; cursor: pointer; padding: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Moduli */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 13px; color: #666; margin-bottom: 0.4rem; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 14px; font-family: inherit; background: white; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #2196f3; }
.field textarea { min-height: 80px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #0b0b0b; }
.segmented { display: inline-flex; border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden; }
.segmented label { padding: 8px 14px; cursor: pointer; font-size: 14px; color: #666; }
.segmented input { display: none; }
.segmented label:has(input:checked) { background: #e3f2fd; color: #1976d2; font-weight: 500; }

/* Login */
.login-box { max-width: 380px; margin: 3rem auto; background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 2rem; }
.login-box h2 { font-size: 18px; font-weight: 600; margin-bottom: 1.5rem; }
.login-box .btn { width: 100%; }
.login-actions { margin-top: 1rem; text-align: center; }

/* Messaggi */
.msg { font-size: 13px; margin-bottom: 1rem; padding: 0.75rem; border-radius: 6px; }
.msg.err { background: #ffebee; color: #c62828; }
.msg.ok { background: #e8f5e9; color: #2e7d32; }
.error { background: #ffebee; border: 1px solid #ef5350; border-radius: 8px; padding: 1rem; color: #c62828; }
.loading { text-align: center; padding: 3rem; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid #e0e0e0; border-top-color: #2196f3; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Elenchi */
.toolbar { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 10px 12px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 14px; background: white; }
.toolbar input { flex: 1; min-width: 180px; }
.list { background: white; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: none; }
a.list-row:hover { background: #fafafa; }
.list-main { min-width: 0; }
.list-title { font-weight: 500; }
.list-sub { font-size: 13px; color: #999; margin-top: 2px; }
.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; background: #f0f0f0; color: #666; white-space: nowrap; }
.tag.privato { background: #e3f2fd; color: #1976d2; }
.tag.azienda { background: #fff3e0; color: #e65100; }
.tag.off { background: #ffebee; color: #c62828; }

/* Schede di dettaglio */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.detail-label { font-size: 12px; color: #999; text-transform: uppercase; font-weight: 500; }
.detail-value { margin-top: 2px; line-height: 1.4; white-space: pre-line; }

/* Tabella permessi */
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 8px; border-bottom: 1px solid #f0f0f0; text-align: center; font-size: 13px; }
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }
.perm-table th { color: #999; font-weight: 500; }

@media (max-width: 600px) {
  .header { padding: 0.75rem 1rem; }
  .logo { font-size: 17px; gap: 8px; }
  .icon { width: 32px; height: 32px; font-size: 16px; }
  .userbar-email { display: none; }
  .nav { padding: 0 1rem; gap: 0 18px; flex-wrap: wrap; }
  .nav .spacer { display: none; }
  .nav select { flex-basis: 100%; margin-bottom: 8px; }
  .container { padding: 0 1rem; margin: 1rem auto; }
  .panel { padding: 1rem; }
}
