/* ConectaVital24 — azul marino y verde. Legible, botones amplios, adaptable. */
:root {
  --navy: #012867;       /* azul del logo */
  --navy-2: #0B3B85;
  --green-bright: #01B961; /* verde del logo (acentos) */
  --green: #00924F;      /* verde para botones: contraste legible con texto blanco */
  --green-2: #007A42;
  --green-soft: #e6f6ef;
  --bg: #f4f7fa;
  --card: #ffffff;
  --text: #1b2733;
  --muted: #5b6b7b;
  --line: #dbe3ea;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --info-soft: #e8f1fb;
  --radius: 12px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--navy-2); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; color: var(--navy); }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; color: var(--navy); }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* ---------- encabezado y menú ---------- */
.topbar {
  background: #fff; color: var(--navy); border-bottom: 3px solid var(--green-bright); box-shadow: 0 1px 6px rgba(1,40,103,.08); display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { height: 46px; width: auto; display: block; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a {
  color: var(--navy); text-decoration: none; padding: .55rem .8rem; border-radius: 10px; font-weight: 500;
  display: flex; align-items: center; gap: .35rem;
}
.nav a.active, .nav a:hover { background: #e9f8f0; }
.nav a.active { box-shadow: inset 0 -3px 0 var(--green-bright); }
.nav .ico { font-size: 1.1rem; }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-weight: 600; padding: .35rem; }

main { max-width: 1180px; margin: 0 auto; padding: 1rem; padding-bottom: 6rem; }

@media (max-width: 760px) {
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); margin: 0;
    justify-content: space-around; padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); z-index: 30;
  }
  .nav a { color: #fff; flex-direction: column; font-size: .72rem; padding: .35rem .3rem; gap: .1rem; min-width: 60px; }
  .nav a.active, .nav a:hover { background: rgba(255,255,255,.14); }
  .nav .ico { font-size: 1.35rem; }
  .topbar { justify-content: center; }
  .brand img { height: 38px; }
  main { padding: .75rem; padding-bottom: 6.5rem; }
}

/* ---------- tarjetas y rejillas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .layout-side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap);
  padding: .6rem 1.1rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--navy);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--navy-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f1b8b2; }
.btn.wa { background: #25D366; border-color: #1eb457; color: #0b3d1f; }
.btn.small { min-height: 38px; padding: .35rem .75rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.quick .btn { min-height: 64px; font-size: 1.05rem; }
@media (max-width: 640px) { .quick { grid-template-columns: 1fr; } .quick .btn { min-height: 54px; } }
.linkbtn { background: none; border: 0; color: var(--navy-2); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- formularios ---------- */
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .95rem; }
label .opt { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time],
input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .7rem; border: 1px solid #c3cfd9; border-radius: 10px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(30,158,106,.25); border-color: var(--green); }
.field { margin-bottom: .8rem; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; min-height: 40px; }
.check input { width: 22px; height: 22px; }
.unit { display: flex; align-items: center; gap: .35rem; }
.unit span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
@media (max-width: 640px) { .vitals { grid-template-columns: 1fr 1fr; } }
.bp { display: flex; align-items: center; gap: .3rem; }
.bp input { min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin: 0 0 .8rem; }
legend { font-weight: 700; color: var(--navy); padding: 0 .3rem; }
details > summary { cursor: pointer; font-weight: 600; color: var(--navy-2); padding: .4rem 0; min-height: 40px; }
.searchbox { position: relative; }
.searchbox input { font-size: 1.05rem; padding-left: 2.4rem; }
.searchbox::before { content: "🔍"; position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); opacity: .6; }
.results { list-style: none; margin: .4rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.results li a { display: block; padding: .7rem .9rem; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
.results li:last-child a { border-bottom: 0; }
.results li a:hover { background: var(--green-soft); }

/* ---------- mensajes ---------- */
.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: .75rem; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: var(--green-soft); color: #0d5c3c; border-color: #b6e3cf; }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: #f4c3bd; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1d9a3; }
.flash.info { background: var(--info-soft); color: var(--navy-2); border-color: #c4d9f0; }

/* ---------- listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.list > li:last-child { border-bottom: 0; }
.appt { display: grid; grid-template-columns: 110px 1fr auto; gap: .75rem; align-items: center; }
.appt .time { white-space: nowrap; font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.appt .who a { font-weight: 600; text-decoration: none; color: var(--text); }
@media (max-width: 640px) { .appt { grid-template-columns: 96px 1fr; } .appt .time { font-size: .95rem; } .appt .actions { grid-column: 1 / -1; } }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef2f6; color: var(--muted); }
.badge.pendiente { background: #eef2f6; color: #3d4b59; }
.badge.confirmada, .badge.entregado, .badge.leido, .badge.final { background: var(--green-soft); color: #0d5c3c; }
.badge.atendida, .badge.aceptado { background: var(--info-soft); color: var(--navy-2); }
.badge.cancelada, .badge.fallido { background: var(--danger-soft); color: var(--danger); }
.badge.no_asistio, .badge.omitido, .badge.draft { background: var(--warn-soft); color: var(--warn); }
.badge.programado { background: #eef2f6; color: #3d4b59; }

/* ---------- expediente ---------- */
.patient-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.patient-head h1 { margin-bottom: .2rem; }
.allergy { border-radius: 10px; padding: .6rem .85rem; font-weight: 600; margin: .6rem 0; }
.allergy.has { background: var(--danger-soft); color: var(--danger); border: 1px solid #f4c3bd; }
.allergy.denies { background: var(--green-soft); color: #0d5c3c; }
.allergy.unknown { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; font-weight: 600; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--navy); border-color: var(--green); }
.timeline .entry { border-left: 3px solid var(--line); padding: .2rem 0 .8rem .9rem; margin-left: .3rem; }
.timeline .entry.final { border-color: var(--green); }
.meta { color: var(--muted); font-size: .85rem; }
.save-state { font-size: .9rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; }
.save-state.saving { background: #eef2f6; color: var(--muted); }
.save-state.saved { background: var(--green-soft); color: #0d5c3c; }
.save-state.error { background: var(--danger-soft); color: var(--danger); }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,247,250,.96); padding: .7rem 0; border-top: 1px solid var(--line); z-index: 5; }
@media (max-width: 760px) { .sticky-actions { bottom: 64px; } }
.prev-consult { max-height: 70vh; overflow: auto; }
.prev-consult .entry { font-size: .92rem; }

/* ---------- agenda ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.week .day { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .45rem; min-height: 140px; }
.week .day.today { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.week .day h3 { margin: 0 0 .35rem; font-size: .88rem; }
.week .slot { display: block; font-size: .82rem; padding: .3rem .35rem; border-radius: 8px; margin-bottom: .3rem; background: var(--info-soft); text-decoration: none; color: var(--text); }
.week .slot.cancelada { text-decoration: line-through; opacity: .6; }
@media (max-width: 760px) { .week { grid-template-columns: 1fr; } .week .day { min-height: 0; } }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented a { padding: .5rem .9rem; text-decoration: none; color: var(--navy); font-weight: 600; min-height: 42px; display: flex; align-items: center; }
.segmented a.active { background: var(--navy); color: #fff; }

/* ---------- documentos ---------- */
.med-row { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; margin-bottom: .6rem; background: #fbfcfd; }
.med-row .grid { gap: .5rem; }
.med-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; font-weight: 700; color: var(--navy); }
.study-cat { margin-bottom: .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid #c3cfd9; border-radius: 999px; padding: .4rem .75rem; cursor: pointer; background: #fff; font-weight: 500; min-height: 40px; }
.chip input { width: 18px; height: 18px; }
.chip.on { background: var(--green-soft); border-color: var(--green); }
.selected-study { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; margin-bottom: .5rem; background: #fbfcfd; }
.preview-pane { background: #e9eef3; border-radius: var(--radius); padding: .6rem; min-height: 280px; position: sticky; top: 70px; }
.preview-pane img { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.15); margin-bottom: .5rem; }
.preview-pane .pv-status { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.mode-switch label { border: 2px solid var(--line); border-radius: 10px; padding: .6rem; cursor: pointer; font-weight: 600; text-align: center; background: #fff; }
.mode-switch input { position: absolute; opacity: 0; }
.mode-switch label.on { border-color: var(--green); background: var(--green-soft); }
.thumb { max-height: 70px; max-width: 160px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 50% / 14px 14px; border: 1px solid var(--line); border-radius: 6px; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 600; font-size: .88rem; }
@media (max-width: 640px) { table.simple.responsive thead { display: none; } table.simple.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; } table.simple.responsive td { display: block; border: 0; padding: .15rem 0; } }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, var(--green-bright) 140%); }
.login-card { background: #fff; border-radius: 16px; padding: 1.6rem; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card .logo { text-align: center; margin-bottom: 1rem; }
.login-card .logo img { width: 100%; max-width: 340px; height: auto; }

@media print { .topbar, .nav, .sticky-actions, .no-print { display: none !important; } main { padding: 0; } }
[data-flex] { flex: 1; min-width: 0; }
.dx-row { margin-bottom: .4rem; flex-wrap: nowrap; }
.wa-compose > summary { list-style: none; }
.wa-compose > summary::-webkit-details-marker { display: none; }
.wa-compose[open] > .card { position: absolute; z-index: 40; width: min(420px, 92vw); right: 1rem; margin-top: .4rem; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.toolbar input[type=date], .toolbar select { width: auto; }
.toolbar .row { flex-wrap: nowrap; }
@media (max-width: 640px) { .toolbar, .toolbar select { width: 100%; } }

.l-short { display: none; }
@media (max-width: 760px) {
  .l-long { display: none; } .l-short { display: inline; }
  .nav a { min-width: 0; flex: 1; font-size: .68rem; padding: .35rem .1rem; }
}
@media (min-width: 761px) and (max-width: 1100px) { .nav a { padding: .5rem .5rem; } .nav .ico { display: none; } }

/* ---------- cobros ---------- */
.fin-line { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .45rem; align-items: end;
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem; margin-bottom: .5rem; background: #fbfcfd; }
.fin-line label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .1rem; }
.fin-line output { display: block; font-weight: 700; padding: .7rem 0; white-space: nowrap; }
.fin-line.is-optional { background: var(--warn-soft); border-style: dashed; }
.fin-line .fl-desc { grid-column: span 2; }
.fin-line .fl-opt, .fin-line .fl-att { grid-column: span 2; }
.fin-line .fl-del { justify-self: end; }
@media (max-width: 640px) { .fin-line { grid-template-columns: 1fr 1fr; } .fin-line .fl-desc, .fin-line .fl-opt, .fin-line .fl-att { grid-column: 1 / -1; } }
.fin-totals, .fin-summary { display: grid; gap: .3rem; align-content: start; }
.fin-totals > div, .fin-summary > div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding: .25rem 0; }
.fin-summary { max-width: 520px; margin-left: auto; }
.fin-summary .big, .big { font-size: 1.12rem; }
.fin-summary h2 { margin-bottom: .2rem; }
.card.fin-summary { margin-left: 0; max-width: none; }
.fin-totals-row { margin-top: .6rem; align-items: start; }
.fee-rule { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.w-price { max-width: 130px; } .w-cur { max-width: 100px; }
.nw { white-space: nowrap; }
@media (max-width: 640px) {
  .sticky-actions { flex-wrap: nowrap; overflow-x: auto; gap: .4rem; }
  .sticky-actions .btn { min-height: 42px; padding: .4rem .7rem; font-size: .88rem; white-space: nowrap; }
  .sticky-actions .small.muted { display: none; }
}
.recv { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; }
.recv-amount { font-size: 1.05rem; white-space: nowrap; }
@media (max-width: 640px) { .recv { grid-template-columns: 1fr auto; } .recv-actions { grid-column: 1 / -1; } }
a.block-link { display: block; text-decoration: none; }
.wa-compose { position: relative; }
.wa-compose textarea { min-height: 150px; }
@media (max-width: 640px) {
  .wa-compose[open] > .card { position: static; width: auto; margin-top: .5rem; box-shadow: none; }
}
