:root {
  --teal: #0e7c86;
  --teal-dark: #0a5b63;
  --teal-light: #e6f4f5;
  --ink: #1d2b33;
  --muted: #64748b;
  --bg: #f2f6f7;
  --card: #ffffff;
  --border: #dde5e8;
  --danger: #e0342c;
  --warning: #b58a00;
  --success: #1d9e4f;
  --info: #1e6fd9;
  --radius: 12px;
  --hover: #f7fbfb;
  --shadow: 0 1px 3px rgba(16, 42, 51, .08), 0 4px 14px rgba(16, 42, 51, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 235px; flex-shrink: 0; background: linear-gradient(180deg, #0a5b63, #08343a);
  color: #d8ecee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 18px 18px 14px; font-size: 21px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 9px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand .tooth { font-size: 24px; }
.sidebar nav { padding: 10px 0; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  color: #cfe6e8; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; border-left: 3px solid #6fd3dc; padding-left: 15px; }
.sidebar nav .section { padding: 12px 18px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8fbfc4; }
.sidebar .userbox { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
.sidebar .userbox .name { color: #fff; font-weight: 600; }
.sidebar .userbox a { color: #9fd8dd; }

.main { flex: 1; padding: 26px 32px 60px; max-width: 1200px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar .sub { color: var(--muted); font-size: 14px; }

/* ---------- Components ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
  transition: box-shadow .2s ease;
}
.card:hover { box-shadow: 0 2px 6px rgba(16, 42, 51, .1), 0 8px 24px rgba(16, 42, 51, .08); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat.teal { border-top: 3px solid var(--teal); }
.stat.green { border-top: 3px solid var(--success); }
.stat.blue { border-top: 3px solid var(--info); }
.stat.red { border-top: 3px solid var(--danger); }
.stat.gold { border-top: 3px solid var(--warning); }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--teal); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; color: #fff;
  box-shadow: 0 3px 10px rgba(10, 91, 99, .25); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.secondary { background: var(--card); color: var(--teal); border-color: var(--teal); }
.btn.secondary:hover { background: var(--teal-light); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b02a24; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.whatsapp { background: #25d366; }
.btn.whatsapp:hover { background: #1da851; }

table.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--hover); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; }
.badge.gray { background: var(--muted); }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.success { background: #e5f6ec; color: #14683a; border: 1px solid #bfe6cf; }
.flash.danger { background: #fdeae9; color: #99231e; border: 1px solid #f5c6c3; }
.flash.info { background: #e8f1fd; color: #174e94; border: 1px solid #c5daf5; }
.flash.warning { background: #fdf6e0; color: #7a5d00; border: 1px solid #efdfa4; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #34454e; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #c4d2d7; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14,124,134,.35); border-color: var(--teal); }
textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.inline-form { display: inline; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 600px at 20% 10%, #12707a, #08343a);
  padding: 30px 16px;
}
.auth-card { background: var(--card); border-radius: 16px; padding: 34px; width: 100%; max-width: 470px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card .logo { text-align: center; font-size: 30px; font-weight: 800; color: var(--teal-dark); margin-bottom: 2px; }
.auth-card .tag { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.price-banner {
  background: linear-gradient(90deg, #0e7c86, #14a08c); color: #fff; border-radius: 10px;
  padding: 12px 16px; text-align: center; margin-bottom: 18px; font-size: 14px;
}
.price-banner b { font-size: 17px; }

/* ---------- Paneles de ayuda (explicaciones para el/la odontólogo/a) ---------- */
.help-panel {
  background: var(--teal-light); border: 1px solid #bcdfe2; border-radius: var(--radius);
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.help-panel summary {
  cursor: pointer; font-weight: 700; padding: 14px 18px; color: var(--teal-dark);
  font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px;
}
.help-panel summary::-webkit-details-marker { display: none; }
.help-panel summary::before { content: "▸"; transition: transform .15s ease; flex-shrink: 0; }
.help-panel[open] summary::before { transform: rotate(90deg); }
.help-panel .help-body { padding: 0 18px 16px 34px; font-size: 14px; }
.help-panel .help-body p { margin: 0 0 10px; }
.help-panel .help-body ol, .help-panel .help-body ul { margin: 0 0 10px; padding-left: 20px; }
.help-panel .help-body li { margin-bottom: 7px; }

/* ---------- Doble factor ---------- */
.otp-input {
  text-align: center; font-size: 26px !important; letter-spacing: 10px;
  font-weight: 700; padding: 12px !important;
}

/* ---------- Cuentas demo en el login ---------- */
.demo-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 16px; background: var(--hover); }
.demo-box .demo-title { font-weight: 700; color: var(--teal-dark); font-size: 14px; text-align: center; margin-bottom: 10px; }
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.demo-grid button {
  border: 1px solid var(--teal); background: var(--card); color: var(--teal-dark);
  border-radius: 9px; padding: 9px 6px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; line-height: 1.35;
}
.demo-grid button:hover { background: var(--teal-light); }
.demo-grid button .demo-emoji { display: block; font-size: 20px; margin-bottom: 2px; }
.demo-box .demo-note { font-size: 11.5px; color: var(--muted); text-align: center; margin: 8px 0 0; }

/* ---------- Agenda ---------- */
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-month .dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-cell { background: var(--card); border: 1px solid var(--border); border-radius: 8px; min-height: 92px; padding: 5px 6px; font-size: 12px; }
.cal-cell.other { background: var(--bg); opacity: .55; }
.cal-cell.today { border: 2px solid var(--teal); }
.cal-cell .daynum { font-weight: 700; margin-bottom: 3px; }
.appt-chip { display: block; border-radius: 5px; color: #fff; padding: 1px 6px; margin-bottom: 2px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-chip:hover { text-decoration: none; opacity: .85; color: #fff; }
.block-chip { display: block; border-radius: 5px; background: repeating-linear-gradient(45deg, #d9dde0, #d9dde0 6px, #c8cdd1 6px, #c8cdd1 12px); color: #444; padding: 1px 6px; margin-bottom: 2px; font-size: 11px; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { background: var(--card); border: 1px solid var(--border); border-radius: 10px; min-height: 200px; padding: 8px; }
.week-col.today { border: 2px solid var(--teal); }
.week-col h4 { margin: 0 0 8px; font-size: 13px; text-align: center; }
.appt-line { border-left: 4px solid var(--teal); background: var(--hover); padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }

/* ---------- Odontograma ---------- */
.odo-wrap { overflow-x: auto; }
#odontogram svg { display: block; margin: 0 auto; }
.odo-tooth polygon, .odo-tooth rect { stroke: #9fb3ba; stroke-width: 1; fill: var(--card); cursor: pointer; }
.odo-tooth polygon:hover, .odo-tooth rect:hover { fill: #dff0f2; }
.odo-tooth text { font-size: 11px; fill: #33565c; text-anchor: middle; pointer-events: none; font-weight: 600; }
.odo-legend { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 8px 0 14px; font-size: 13px; }
.odo-legend .swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.odo-panel { background: var(--teal-light); border: 1px solid #bcdfe2; border-radius: 10px; padding: 14px; }
.odo-step { font-weight: 700; color: var(--teal-dark); margin: 12px 0 6px; font-size: 14px; }
.odo-chip {
  border: 1.5px solid var(--border); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: border-color .1s, box-shadow .1s;
}
.odo-chip:hover { border-color: var(--teal); }
.odo-chip.active { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(14,124,134,.25); font-weight: 700; }
.odo-tooth .sel-face { stroke: #0e7c86; stroke-width: 2.5; }
.odo-readonly .odo-tooth polygon, .odo-readonly .odo-tooth rect { cursor: default; }
.odo-arch { font-size: 11px; letter-spacing: 2px; fill: #7b969c; text-anchor: middle; font-weight: 700; }
.odo-midline { stroke: #c3d4d8; stroke-width: 1; }
.odo-summary { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 14px; font-size: 13px; }
.odo-sum-chip { background: var(--hover); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
.odo-sum-chip .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
#odo-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #123a40; color: #fff; padding: 11px 20px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: 14px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
}
#odo-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#odo-toast a { color: #8fe3d9; font-weight: 700; margin-left: 6px; }

@media print {
  .sidebar, .tabs, .no-print, .btn, .flash, .theme-toggle, #odo-toast, .odo-panel,
  .mobile-topbar, .sidebar-backdrop { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
}

/* ---------- Progreso ---------- */
.progress { background: #e5ecef; border-radius: 999px; height: 12px; overflow: hidden; }
.progress > div { background: linear-gradient(90deg, #14a08c, #0e7c86); height: 100%; border-radius: 999px; }

/* ---------- Gráficos ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.chart-bars .bar > i { display: block; width: 100%; background: linear-gradient(180deg, #14a08c, #0e7c86); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart-bars .bar b { font-size: 10.5px; color: var(--ink); margin-bottom: 2px; font-style: normal; }
.chart-bars .bar span { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 8px 8px 0 0; font-weight: 600; color: var(--muted); font-size: 14px; }
.tabs a.active { background: var(--card); color: var(--teal-dark); border: 1px solid var(--border); border-bottom: 2px solid var(--card); margin-bottom: -2px; }
.tabs a:hover { text-decoration: none; color: var(--teal-dark); }

.patient-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--teal-light); color: var(--teal-dark); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.gallery .item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.gallery .item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.gallery .item .meta { padding: 8px 10px; font-size: 12.5px; }

/* ---------- Chatbot: vinculación por QR ---------- */
.dot-pending {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #ffc93c; margin-left: 6px; box-shadow: 0 0 6px #ffc93c;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.qr-card { display: flex; gap: 30px; align-items: flex-start; flex-wrap: wrap; }
.qr-side { text-align: center; flex-shrink: 0; }
.qr-img {
  width: 240px; height: 240px; border: 1px solid var(--border); border-radius: 14px;
  padding: 10px; background: #fff; box-shadow: var(--shadow);
}
.qr-status { margin-top: 10px; font-weight: 600; color: var(--warning); }
.qr-steps { padding-left: 20px; line-height: 1.9; }
.qr-card > div:last-child { flex: 1; min-width: 260px; }

/* ---------- Chat (portal del paciente y bandeja del consultorio) ---------- */
.chat-card { padding: 0; overflow: hidden; }
.chat-box {
  height: 460px; overflow-y: auto; padding: 20px;
  background: linear-gradient(180deg, #eef6f7, #f6fafa);
}
.chat-msg { display: flex; margin-bottom: 12px; }
.chat-msg.paciente, .chat-msg.mine { justify-content: flex-end; }
.chat-msg .bubble {
  max-width: 75%; padding: 10px 14px; border-radius: 14px; font-size: 14px;
  background: var(--card); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16,42,51,.06);
}
.chat-msg.paciente .bubble, .chat-msg.mine .bubble {
  background: var(--teal); color: #fff; border-color: var(--teal);
  border-bottom-right-radius: 4px;
}
.chat-msg.bot .bubble { border-bottom-left-radius: 4px; background: var(--card); }
.chat-msg.consultorio .bubble { background: #e8f1fd; border-color: #c5daf5; border-bottom-left-radius: 4px; }
.chat-msg .who { font-size: 11.5px; font-weight: 700; margin-bottom: 3px; opacity: .8; }
.chat-msg .text { white-space: pre-line; }
.chat-msg .time { font-size: 10.5px; opacity: .65; margin-top: 4px; text-align: right; }
.chat-form { display: flex; gap: 10px; padding: 14px 16px; background: var(--card); border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }
.chat-form .btn { flex-shrink: 0; }

/* ---------- Portal del paciente ---------- */
.portal-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.portal-topbar {
  background: linear-gradient(90deg, #0a5b63, #0e7c86); color: #fff;
  padding: 14px 26px; display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; box-shadow: 0 2px 10px rgba(8, 52, 58, .25);
}
.portal-brand { font-size: 19px; font-weight: 700; }
.portal-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.portal-nav a {
  color: #d8ecee; font-weight: 600; padding: 7px 14px; border-radius: 8px; font-size: 14px;
}
.portal-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.portal-nav a.active { background: rgba(255,255,255,.2); color: #fff; }
.portal-main { flex: 1; padding: 26px 22px 50px; max-width: 980px; margin: 0 auto; width: 100%; }
.portal-footer {
  text-align: center; padding: 16px; color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--border); background: var(--card);
}

/* ══════════ Celulares y tablets (menú deslizante + ajustes táctiles) ══════════ */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  /* Barra superior fija con botón de menú (reemplaza a la barra lateral) */
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 60;
    background: linear-gradient(90deg, #0a5b63, #0e7c86); color: #fff;
    padding: 9px 12px; box-shadow: 0 2px 10px rgba(8, 52, 58, .3);
  }
  .mobile-topbar .nav-toggle {
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3);
    color: #fff; font-size: 20px; line-height: 1; border-radius: 9px;
    padding: 8px 13px; cursor: pointer; font-family: inherit;
  }
  .mobile-topbar .mt-brand { font-weight: 700; font-size: 17px; flex: 1; color: #fff; }
  .mobile-topbar .mt-brand:hover { text-decoration: none; }
  .mobile-topbar .mt-action { color: #fff; font-size: 19px; padding: 6px 8px; }
  .mobile-topbar .mt-action:hover { text-decoration: none; }
  .mobile-topbar .badge { font-size: 11px; vertical-align: top; }

  /* La barra lateral se vuelve un cajón que entra desde la izquierda */
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: min(300px, 84vw); height: 100vh; height: 100dvh;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.4);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(8, 20, 24, .5); z-index: 70;
  }
  body.nav-open { overflow: hidden; }
  .sidebar nav a { padding: 13px 18px; }   /* objetivos táctiles más cómodos */
  .sidebar nav a.active { padding-left: 15px; }

  .main { padding: 16px 12px 70px; max-width: 100%; }
  .topbar h1 { font-size: 21px; }
  .card { padding: 16px 14px; }

  /* 16px evita que iPhone haga zoom automático al tocar un campo */
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=time], input[type=number], input[type=file], select, textarea { font-size: 16px; }
  .btn { padding: 10px 16px; }
  .btn.small { padding: 6px 10px; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs a { white-space: nowrap; flex-shrink: 0; }

  /* Agenda: mes y semana se deslizan de lado con el dedo */
  .cal-month { overflow-x: auto; -webkit-overflow-scrolling: touch; grid-template-columns: repeat(7, minmax(88px, 1fr)); padding-bottom: 6px; }
  .cal-cell { min-height: 74px; }
  .week-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; grid-template-columns: repeat(7, minmax(155px, 1fr)); padding-bottom: 6px; }

  .chat-box { height: 60vh; height: 60dvh; padding: 14px 10px; }
  .chat-msg .bubble { max-width: 88%; }
  .chat-form { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .qr-card { justify-content: center; }

  .portal-topbar { padding: 10px 12px; }
  .portal-nav a { padding: 9px 12px; }
  .portal-main { padding: 18px 12px 40px; }

  .patient-head { flex-wrap: wrap; }
  .auth-card { padding: 24px 18px; }
  .trial-number { font-size: 48px; }
  .theme-toggle-float { top: 10px; right: 10px; }
}

@media (max-width: 600px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 21px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

.qr-loading {
  width: 240px; height: 240px; border: 2px dashed var(--border); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); background: var(--card); font-size: 14px;
}

/* ══════════ Modo oscuro (html[data-theme="dark"]) ══════════ */
html[data-theme="dark"] {
  --teal: #1a99a4;
  --teal-dark: #7fd6de;
  --teal-light: #10333a;
  --ink: #e3edf0;
  --muted: #94aab3;
  --bg: #0d181c;
  --card: #142329;
  --border: #263b43;
  --hover: #1a2e35;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
}
html[data-theme="dark"] a { color: #6fd0d9; }
html[data-theme="dark"] .btn { color: #fff; }
html[data-theme="dark"] .btn:hover { background: #23aab6; color: #fff; }
html[data-theme="dark"] .card:hover { box-shadow: 0 2px 6px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.4); }
html[data-theme="dark"] label { color: #b8cad1; }
html[data-theme="dark"] input[type=text], html[data-theme="dark"] input[type=email],
html[data-theme="dark"] input[type=password], html[data-theme="dark"] input[type=date],
html[data-theme="dark"] input[type=time], html[data-theme="dark"] input[type=number],
html[data-theme="dark"] input[type=file], html[data-theme="dark"] select,
html[data-theme="dark"] textarea { border-color: var(--border); }
html[data-theme="dark"] .flash.success { background: #0e2b1b; color: #7fd9a5; border-color: #1c4a30; }
html[data-theme="dark"] .flash.danger  { background: #33120f; color: #f1948c; border-color: #5c221d; }
html[data-theme="dark"] .flash.info    { background: #0f2038; color: #8ab6ee; border-color: #1d3a63; }
html[data-theme="dark"] .flash.warning { background: #2e2405; color: #e5c55e; border-color: #57470f; }
html[data-theme="dark"] .help-panel { border-color: #1d4750; }
html[data-theme="dark"] .odo-panel { border-color: #1d4750; }
html[data-theme="dark"] .progress { background: #243940; }
html[data-theme="dark"] .chat-box { background: linear-gradient(180deg, #0f1e23, #12262c); }
html[data-theme="dark"] .chat-msg.consultorio .bubble { background: #16344d; border-color: #1d456a; }
html[data-theme="dark"] .odo-tooth polygon:hover, html[data-theme="dark"] .odo-tooth rect:hover { fill: #1d3d45; }
html[data-theme="dark"] .odo-tooth text { fill: #a8ccd2; }
html[data-theme="dark"] .odo-tooth .sel-face { stroke: #4fd8c8; }
html[data-theme="dark"] .odo-arch { fill: #5f8189; }
html[data-theme="dark"] .odo-midline { stroke: #2a4a52; }
html[data-theme="dark"] .odo-chip.active { box-shadow: 0 0 0 2px rgba(79,216,200,.35); }
html[data-theme="dark"] .odo-step { color: #7fd6cb; }
html[data-theme="dark"] .chart-bars .bar b { color: var(--ink); }
html[data-theme="dark"] .block-chip { background: repeating-linear-gradient(45deg, #2a3a40, #2a3a40 6px, #223035 6px, #223035 12px); color: #aabbc2; }

/* ---------- Botón claro/oscuro ---------- */
.theme-toggle {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3);
  color: inherit; border-radius: 999px; padding: 4px 12px; font-size: 12.5px;
  cursor: pointer; font-family: inherit; font-weight: 600; line-height: 1.4;
}
.theme-toggle:hover { background: rgba(255,255,255,.22); }
.theme-toggle-float { position: fixed; top: 14px; right: 14px; z-index: 50; color: #e6f4f5; }

/* ---------- Suscripción gamificada ---------- */
.trial-hero { text-align: center; border-top: 4px solid var(--teal); }
.trial-hero.trial-warning { border-top-color: var(--warning); }
.trial-hero.trial-danger { border-top-color: var(--danger); }
.trial-number { font-size: 64px; font-weight: 800; color: var(--teal-dark); line-height: 1; }
.trial-warning .trial-number { color: var(--warning); }
.trial-danger .trial-number { color: var(--danger); }
.trial-label { color: var(--muted); font-weight: 600; margin-top: 4px; }
.trial-breakdown { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.trial-chip {
  background: var(--teal-light); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; font-size: 13px; color: var(--ink);
}
.trial-chip b { font-size: 15px; color: var(--teal-dark); }
.trial-chip-off { opacity: .55; }
.trial-chip-total { background: linear-gradient(135deg, var(--teal), #14a08c); color: #fff; border: none; }
.trial-chip-total b { color: #fff; }
.ref-stat { flex: 1; min-width: 110px; text-align: center; background: var(--teal-light); border-radius: 10px; padding: 12px; }
.ref-num { font-size: 30px; font-weight: 700; color: var(--teal-dark); }

/* ---------- Primeros pasos (onboarding) ---------- */
.onboarding { border-top: 4px solid var(--teal); }
.onboard-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.onboard-step {
  display: block; border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  background: var(--hover); color: var(--ink); font-size: 13.5px;
}
.onboard-step:hover { text-decoration: none; border-color: var(--teal); background: var(--teal-light); color: var(--ink); }
.onboard-step b { display: block; margin: 6px 0 4px; color: var(--teal-dark); }
.onboard-step .muted { display: block; }
.onboard-num {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
  background: var(--teal); color: #fff; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
