:root {
  --navy: #0f2a43;
  --navy-2: #16324f;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --gold: #b08d57;
  --gold-light: #c8a86f;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a2430;
  --muted: #5b6b7b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,42,67,.08), 0 8px 24px rgba(15,42,67,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--navy); line-height: 1.2; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 22px; border-radius: 9px;
  font-size: .95rem; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  transition: all .15s ease; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: .95rem; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.msg { font-size: .88rem; min-height: 1.2em; margin-top: 10px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-client { background: #dbeafe; color: #1d4ed8; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fee2e2; color: #b91c1c; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.spinner {
  width: 16px; height: 16px; border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Responsive / móvil ================= */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { overflow-x: clip; }
img, svg, video, canvas { max-width: 100%; height: auto; }

@media (max-width: 640px) {
  .container { padding: 0 14px; }
  .card { padding: 16px; }
  .btn { padding: 10px 15px; font-size: .92rem; }
  /* iOS hace zoom al enfocar un campo de menos de 16px */
  input[type=text], input[type=password], input[type=email], input[type=number],
  input[type=time], input[type=tel], input[type=date], select, textarea { font-size: 16px; }
  table th, table td { padding: 8px 10px; font-size: .88rem; }
  .modal .actions, .actions { flex-wrap: wrap; }
  .modal .actions .btn, .actions .btn { flex: 1 1 auto; }
  .modal h3 { font-size: 1.05rem; }
  /* Tablas → tarjetas apiladas en móvil (sin scroll horizontal) */
  .tbl thead, .card > table thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td,
  .card > table, .card > table tbody, .card > table tr, .card > table td { display: block; width: 100%; }
  .tbl tr, .card > table tr {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 10px; box-shadow: none;
  }
  .tbl tr.hist-row { background: #f8fafc; }
  .tbl td, .card > table td { border: none; padding: 3px 0; }
  .tbl td:empty, .card > table td:empty { display: none; }
  .tbl td::before, .card > table td::before {
    display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); font-weight: 600; margin-bottom: 1px;
  }
  #panel-pacientes .tbl td:nth-child(1)::before { content: "Paciente"; }
  #panel-pacientes .tbl td:nth-child(2)::before { content: "Celular"; }
  #panel-pacientes .tbl td:nth-child(3)::before { content: "Próxima cita"; }
  #panel-pacientes .tbl td:nth-child(4)::before { content: "Última visita"; }
  #panel-pacientes .tbl td:nth-child(5)::before { content: "Notas"; }
  #panel-pacientes .tbl td:nth-child(6)::before { content: "Acciones"; }
  #panel-pacientes .tbl tr.hist-row td::before { content: none; }
  #panel-podologas .tbl td:nth-child(1)::before { content: none; }
  #panel-podologas .tbl td:nth-child(2)::before { content: "Nombre"; }
  #panel-podologas .tbl td:nth-child(3)::before { content: "Horario"; }
  #panel-podologas .tbl td:nth-child(4)::before { content: "Estado"; }
  #panel-podologas .tbl td:nth-child(5)::before { content: "Acciones"; }
  #panel-usuarios .card > table td:nth-child(1)::before { content: "Usuario"; }
  #panel-usuarios .card > table td:nth-child(2)::before { content: "Nombre"; }
  #panel-usuarios .card > table td:nth-child(3)::before { content: "Rol"; }
  #panel-usuarios .card > table td:nth-child(4)::before { content: "Cliente(s)"; }
  #panel-usuarios .card > table td:nth-child(5)::before { content: "Estado"; }
  #panel-usuarios .card > table td:nth-child(6)::before { content: none; }
  #panel-clientes .card > table td:nth-child(1)::before { content: "Nombre"; }
  #panel-clientes .card > table td:nth-child(2)::before { content: "Zona horaria"; }
  #panel-clientes .card > table td:nth-child(3)::before { content: "Estado"; }
  #panel-clientes .card > table td:nth-child(4)::before { content: none; }
  #panel-auditoria .card > table td:nth-child(1)::before { content: "Fecha"; }
  #panel-auditoria .card > table td:nth-child(2)::before { content: "Acción"; }
  #panel-auditoria .card > table td:nth-child(3)::before { content: "Objetivo"; }
  #panel-auditoria .card > table td:nth-child(4)::before { content: "Cliente"; }
  #panel-auditoria .card > table td:nth-child(5)::before { content: "Actor"; }
  div[style*="overflow:auto"], div[style*="overflow: auto"] { -webkit-overflow-scrolling: touch; }
}
