:root {
  --primary: #0F6E56;
  --primary-light: #1D9E75;
  --bg: #F7F7F5;
  --card: #FFFFFF;
  --border: #E4E2DA;
  --text: #2C2C2A;
  --text-muted: #5F5E5A;
  --danger: #A32D2D;
  --warning: #854F0B;
  --warning-bg: #FAEEDA;
  --success: #27500A;
  --success-bg: #EAF3DE;
  --danger-bg: #FCEBEB;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header.topbar {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
header.topbar button.link {
  background: none; border: none; color: white; font-size: 14px;
  opacity: 0.9; cursor: pointer; padding: 4px;
}

main { flex: 1; padding: 16px; padding-bottom: 90px; }

nav.tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
nav.tabbar button {
  flex: 1; background: none; border: none; padding: 6px;
  color: var(--text-muted); font-size: 12px; cursor: pointer;
}
nav.tabbar button.active { color: var(--primary); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge.al_dia { background: var(--success-bg); color: var(--success); }
.badge.por_vencer { background: var(--warning-bg); color: var(--warning); }
.badge.vencida { background: var(--danger-bg); color: var(--danger); }
.badge.sin_visitas { background: #EFEDE6; color: var(--text-muted); }
.badge.estado-agendada { background: #EFEDE6; color: var(--text-muted); }
.badge.estado-en_curso { background: var(--warning-bg); color: var(--warning); }
.badge.estado-completada { background: var(--success-bg); color: var(--success); }

label { display: block; font-size: 13px; color: var(--text-muted); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: white;
}
textarea { resize: vertical; min-height: 80px; }

button.primary {
  width: 100%; padding: 13px; background: var(--primary); color: white;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 16px;
}
button.primary:disabled { opacity: 0.5; }
button.secondary {
  width: 100%; padding: 13px; background: white; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 8px; font-size: 15px;
  font-weight: 600; cursor: pointer; margin-top: 10px;
}
button.danger-outline {
  width: 100%; padding: 13px; background: white; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 8px; font-size: 15px;
  font-weight: 600; cursor: pointer; margin-top: 10px;
}

.row { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--text-muted); font-size: 13px; }
.error-box {
  background: var(--danger-bg); color: var(--danger); padding: 10px 12px;
  border-radius: 8px; font-size: 14px; margin-bottom: 12px;
}
.success-box {
  background: var(--success-bg); color: var(--success); padding: 10px 12px;
  border-radius: 8px; font-size: 14px; margin-bottom: 12px;
}
.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }

canvas#signature-pad {
  width: 100%; height: 180px; border: 1px dashed var(--border);
  border-radius: 8px; background: white; touch-action: none;
}

.photo-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; margin: 4px; }
.photo-row { display: flex; flex-wrap: wrap; margin-top: 8px; }

.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
  padding: 24px;
}
.login-wrap h1 { text-align: center; color: var(--primary); margin-bottom: 4px; }
.login-wrap p.subtitle { text-align: center; color: var(--text-muted); margin-top: 0; margin-bottom: 24px; font-size: 14px; }

.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white; border-radius: 50%; display: inline-block;
  animation: spin 0.7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
