/* Dr.Agro Club — estilos compartidos. Paleta tomada de la maqueta acordada. */
:root {
  --ink: #17271f;
  --muted: #5f6b63;          /* más oscuro que la maqueta para contraste AA */
  --faint: #8a948d;
  --line: #e4ebe5;
  --paper: #ffffff;
  --bg: #f6f8f5;
  --green: #276749;
  --green-dark: #1f5b3c;
  --green-soft: #edf5ef;
  --mint: #e8f3ec;
  --orange: #b4652a;
  --orange-soft: #fbf0e6;
  --red: #b3261e;
  --red-soft: #fcecea;
  --shadow: 0 16px 44px #24382b0f;
  --radius: 15px;
  --focus: 0 0 0 3px #27674966;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { font-family: Manrope, "DM Sans", system-ui, sans-serif; margin: 0; letter-spacing: -.3px; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--green); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- estructura ---------- */
.layout { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.side {
  background: var(--paper); border-right: 1px solid var(--line); padding: 24px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; font: 800 18px Manrope, sans-serif; }
.logo {
  width: 36px; height: 36px; border-radius: 12px; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 19px; flex: none;
}
.nav-label { color: var(--faint); text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; padding: 0 12px 8px; }
.nav { display: grid; gap: 4px; }
.nav a, .nav button {
  color: #55635a; text-decoration: none; border-radius: 10px; padding: 10px 12px; display: flex; gap: 11px;
  align-items: center; font: 600 14px "DM Sans", sans-serif; background: none; border: 0; cursor: pointer; text-align: left;
}
.nav a:hover, .nav button:hover { background: #f3f7f4; }
.nav a[aria-current="page"], .nav button[aria-current="page"] { background: var(--green-soft); color: var(--green); }
.ico { width: 19px; text-align: center; font-size: 16px; }
.who { margin-top: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.who strong { font-size: 13px; display: block; }
.who small { color: var(--muted); font-size: 12px; }
.main { width: 100%; max-width: 1360px; padding: 30px 40px 60px; margin: 0 auto; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.crumb { font-size: 12px; color: var(--muted); }
.sub { color: var(--muted); margin-top: 4px; }

.demo-banner {
  background: var(--orange-soft); color: #7a3f12; border-bottom: 1px solid #f0d7c0;
  padding: 8px 16px; font-size: 13px; text-align: center; font-weight: 600;
}
.offline-banner { background: var(--red-soft); color: var(--red); padding: 8px 16px; text-align: center; font-weight: 600; font-size: 13px; }

/* ---------- tarjetas ---------- */
.card { background: var(--paper); border: 1px solid #e9eee9; border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.small-muted { font-size: 12px; color: var(--muted); margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 17px 18px; }
.kpi-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.kpi-icon { height: 30px; width: 30px; background: #f2f7f3; border-radius: 9px; display: grid; place-items: center; font-size: 15px; }
.number { font: 700 24px Manrope, sans-serif; margin: 10px 0 2px; }
.kpi small { color: var(--muted); font-size: 12px; }

/* ---------- formularios ---------- */
.field { display: grid; gap: 5px; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: #3d4a42; }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5ddd7; border-radius: 10px;
  padding: 10px 12px; width: 100%; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: var(--focus); outline: none; }
input[aria-invalid="true"] { border-color: var(--red); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; accent-color: var(--green); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.money-input { position: relative; }
.money-input::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money-input input { padding-left: 24px; text-align: right; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid transparent; background: var(--green); color: #fff; border-radius: 10px; padding: 10px 15px;
  font: 700 14px "DM Sans", sans-serif; cursor: pointer; min-height: 42px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; border-color: #d5ddd7; color: #34423a; }
.btn.secondary:hover { background: #f4f7f5; }
.btn.danger { background: #fff; border-color: #e7c0bc; color: var(--red); }
.btn.big { min-height: 52px; font-size: 16px; padding: 12px 22px; }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.btn.link { background: none; border: 0; color: var(--green); padding: 4px; min-height: 0; }

.segmented { display: flex; background: #e8ece8; border-radius: 10px; padding: 4px; gap: 3px; flex-wrap: wrap; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: block; text-align: center; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font: 600 13px "DM Sans", sans-serif; color: #5b665f;
}
.segmented input:checked + span { background: #fff; color: var(--green); box-shadow: 0 1px 5px #20362814; }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- tablas y listas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th { font-size: 11px; color: #7d877f; text-transform: uppercase; letter-spacing: .6px; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { font-size: 14px; padding: 11px 8px; border-bottom: 1px solid #f0f3f0; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--green-soft); color: #2a6d49; white-space: nowrap; }
.badge.off { background: #eef0ee; color: #6a746d; }
.badge.warn { background: var(--orange-soft); color: #8a4a17; }
.plus { color: var(--green); font-weight: 700; }
.minus { color: var(--orange); font-weight: 700; }
.list-item { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f0f2f0; }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e8e6da; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info strong { font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .info small { color: var(--muted); font-size: 12px; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .big-ico { font-size: 28px; display: block; margin-bottom: 6px; }
.note { background: var(--green-soft); border: 1px solid #d9eadf; border-radius: 12px; padding: 12px 14px; font-size: 13px; color: #2c4a37; }
.note.warn { background: var(--orange-soft); border-color: #f0d7c0; color: #6f3a10; }
.note.error { background: var(--red-soft); border-color: #f0c9c5; color: var(--red); }
.secret { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; word-break: break-all; background: #f4f6f4; padding: 10px; border-radius: 8px; border: 1px dashed #c9d3cc; }

.skeleton { background: linear-gradient(90deg, #eef2ef 25%, #f6f8f6 50%, #eef2ef 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- avisos ---------- */
.toast-area { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 460px); }
.toast { background: #1e3327; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px #0003; font-size: 14px; }
.toast.error { background: var(--red); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(94vw, 520px); box-shadow: 0 30px 80px #0003; color: var(--ink); }
dialog::backdrop { background: #17271f66; }
dialog .dlg-body { padding: 22px; display: grid; gap: 14px; }

/* ---------- acceso ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(100%, 420px); padding: 28px; display: grid; gap: 16px; }

/* ---------- caja ---------- */
.steps { display: flex; gap: 8px 14px; margin: 0 0 18px; padding: 0; list-style: none; flex-wrap: wrap; }
.step { font-size: 13px; font-weight: 700; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #e8ece8; font-size: 12px; }
.step.on { color: var(--green); }
.step.on b { background: var(--green); color: #fff; }
.step.done b { background: var(--mint); color: var(--green); }
.cust-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; background: var(--green-soft); border: 1px solid #d9eadf; }
.cust-card .bal { margin-left: auto; text-align: right; }
.cust-card .bal strong { font: 800 22px Manrope, sans-serif; display: block; color: var(--green); }
.line-row { display: grid; grid-template-columns: 1.1fr 1.6fr 80px 130px 42px; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px dashed #e8ede9; }
.line-row:last-of-type { border-bottom: 0; }
.line-row .field > span { font-size: 12px; }
.totals { display: grid; gap: 6px; font-size: 15px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font: 800 20px Manrope, sans-serif; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.totals .earn { color: var(--green); font-weight: 700; }
.success-hero { text-align: center; padding: 26px 16px; display: grid; gap: 8px; justify-items: center; }
.success-hero .tick { width: 58px; height: 58px; border-radius: 50%; background: var(--mint); color: var(--green); display: grid; place-items: center; font-size: 30px; }
video.scanner { width: 100%; border-radius: 12px; background: #000; max-height: 320px; object-fit: cover; }

/* ---------- vista del cliente ---------- */
.mobile-page { max-width: 460px; margin: 0 auto; min-height: 100vh; background: #fafbf9; }
.mhead { padding: 26px 20px 34px; background: var(--green-dark); color: #fff; position: relative; overflow: hidden; }
.mhead::after { content: "✳"; position: absolute; font-size: 150px; color: #ffffff0d; right: -12px; top: -40px; }
.mbrand { font-size: 13px; opacity: .85; }
.mhead h1 { font-size: 22px; margin: 14px 0 4px; }
.mhead p { opacity: .85; font-size: 13px; }
.balance { margin: -20px 16px 0; background: #fff; border-radius: 16px; padding: 18px; position: relative; box-shadow: 0 8px 20px #2038280f; display: flex; justify-content: space-between; align-items: center; }
.balance small { color: var(--muted); }
.balance strong { display: block; font: 800 30px Manrope, sans-serif; margin-top: 4px; }
.ring { --p: 0; width: 58px; height: 58px; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--p) * 1%), #d7e8dc 0); display: grid; place-items: center; }
.ring span { width: 44px; height: 44px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--green); }
.mcontent { padding: 20px 16px 40px; display: grid; gap: 18px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.qr-card img { width: 200px; height: 200px; image-rendering: pixelated; }
.qr-code { font: 800 22px ui-monospace, Menlo, monospace; letter-spacing: 2px; }
.coupon { background: #eff6f0; border: 1px solid #e2eee5; border-radius: 13px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.coupon .gift { width: 40px; height: 40px; background: #fff; border-radius: 11px; display: grid; place-items: center; font-size: 20px; flex: none; }
.coupon b { margin-left: auto; font: 700 14px Manrope, sans-serif; color: var(--green); white-space: nowrap; }
.history { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; }
.progress { height: 6px; background: #edf1ed; border-radius: 10px; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: #4c8a62; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-even { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; margin-right: auto; font-size: 16px; }
  .nav-label { display: none; }
  .nav { display: flex; overflow-x: auto; width: 100%; order: 3; gap: 4px; padding-bottom: 2px; }
  .nav a, .nav button { white-space: nowrap; padding: 8px 10px; }
  .who { margin: 0; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .who > div { display: none; }
  .main { padding: 20px 16px 48px; }
  h1 { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .line-row { grid-template-columns: 1fr 1fr; }
  .line-row .desc { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .number { font-size: 20px; }
  .panel { padding: 16px; }
}

/* utilidades sin estilos en línea (la CSP no permite atributos style) */
.brand.flush { padding: 0; }
.stack.tight { gap: 14px; }
.mt { margin-top: 14px; }
.muted { color: var(--muted); }
.right { text-align: right; }
#top-actions select { width: auto; min-width: 170px; }
@media (max-width: 480px) { #top-actions, #top-actions select { width: 100%; } }
.grid-crud { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1180px) { .grid-crud { grid-template-columns: 1fr; } }
.table td .btn { white-space: nowrap; }
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side > .nav { min-width: 0; flex: 1 1 100%; max-width: 100%; }
}
.layout { grid-template-columns: 240px minmax(0, 1fr); }
@media (max-width: 820px) { .layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1180px) { .grid-crud { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) { .grid-2, .grid-even { grid-template-columns: minmax(0, 1fr); } }
.card { min-width: 0; }

/* ---------- app del cliente (/c/{programa}) ---------- */
body.club { background: #fafbf9; }
.club-card { margin: -20px 16px 0; position: relative; background: #fff; border-radius: 16px; padding: 20px; box-shadow: 0 8px 20px #2038280f; display: grid; gap: 14px; }
.code-input { font: 800 28px ui-monospace, Menlo, monospace; letter-spacing: 10px; text-align: center; }
.mhead .btn.secondary { background: #ffffff1f; color: #fff; border-color: #ffffff40; }
.mhead .btn.secondary:hover { background: #ffffff33; }
.mhead::after { pointer-events: none; }
.mhead > * { position: relative; z-index: 1; }
