/* La Esperanza — sistema de diseño común (escritorio, móvil y clientes) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #1d3461;
  --navy-2: #2a4a85;
  --green: #12a07a;
  --green-2: #0e8566;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #15233f;
  --muted: #6b7a93;
  --line: #e3e8f0;
  --danger: #d64545;
  --warn: #e8a317;
  --info: #2f7de1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 35, 70, .06), 0 8px 24px rgba(20, 35, 70, .07);
  --shadow-lg: 0 20px 50px rgba(20, 35, 70, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1524; --surface: #16203a; --surface-2: #1b2744; --text: #e8edf7; --muted: #94a3bf;
    --line: #26355a; --navy: #8fb0ff; --navy-2: #b5ccff; --green: #2fc597; --green-2: #22a77f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1524; --surface: #16203a; --surface-2: #1b2744; --text: #e8edf7; --muted: #94a3bf;
  --line: #26355a; --navy: #8fb0ff; --navy-2: #b5ccff; --green: #2fc597; --green-2: #22a77f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.err { color: var(--danger); font-weight: 500; min-height: 1.2em; margin: .5em 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* Cards & layout */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.card.flat { box-shadow: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.spacer { flex: 1; }
.center-page { min-height: 100vh; padding: 16px; }

/* Forms */
label { display: block; font-weight: 600; font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent); }
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0 6px 0 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; font: inherit; font-weight: 600; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
  transition: transform .08s, background .15s, box-shadow .15s; min-height: 46px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--green), var(--green-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--green) 35%, transparent); }
.btn.navy { background: var(--navy); border-color: transparent; color: #fff; }
.btn.danger { color: var(--danger); }
.btn.wa { background: #25d366; color: #fff; border-color: transparent; }
.btn.big { width: 100%; padding: 18px; font-size: 1.05rem; border-radius: 14px; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }

/* Segmented control */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 8px; border-radius: 10px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Stepper */
.steps { display: flex; list-style: none; margin: 0 0 18px; padding: 0; gap: 6px; counter-reset: s; }
.steps li { flex: 1; text-align: center; font-size: .78rem; font-weight: 600; color: var(--muted); position: relative; padding-top: 34px; counter-increment: s; }
.steps li::before {
  content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 2px solid var(--line); color: var(--muted); font-weight: 700;
}
.steps li.on { color: var(--text); }
.steps li.on::before { background: var(--navy); border-color: var(--navy); color: #fff; }
.steps li.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: #fff; }
.step { display: none; animation: fade .2s ease; }
.step.on { display: block; }
.stepnav { display: flex; gap: 10px; margin-top: 16px; }
.stepnav .btn { flex: 1; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Guide (paso a paso) */
.guide {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 14px;
  border-radius: 14px; background: color-mix(in srgb, var(--green) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); font-size: .9rem;
}
.guide .gi { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; }
.guide b { display: block; margin-bottom: 2px; }
.howto { counter-reset: h; list-style: none; padding: 0; margin: 0; }
.howto li { counter-increment: h; display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.howto li:last-child { border: 0; }
.howto li::before { content: counter(h); flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%;
}
.item:hover { border-color: var(--green); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: .85rem; }
.item.sel { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.b-solicitado { background: #fff4dc; color: #a26a00; border-color: #f5dca0; }
.b-recogido, .b-en_transito { background: #e6efff; color: #2457b8; border-color: #c4d6fb; }
.b-en_agencia_origen, .b-en_agencia_destino { background: #efe9ff; color: #5b3fb5; border-color: #d8cbfb; }
.b-en_reparto { background: #e0f6ff; color: #0b6f99; border-color: #b6e6f8; }
.b-entregado, .b-pagado { background: #dcf5ec; color: #0b7a57; border-color: #b0e6d1; }
.b-cancelado { background: #fde6e6; color: #b23030; border-color: #f6c4c4; }
.b-a_cobrar, .b-pendiente { background: #fff1e6; color: #b05a12; border-color: #f7d3b3; }

/* Package type picker */
.pkgs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pkg {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  padding: 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.pkg:active { transform: scale(.98); }
.pkg .pi { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.pkg small { color: var(--muted); font-size: .75rem; }
.pkg em { font-style: normal; font-size: .75rem; font-weight: 700; color: var(--green-2); margin-top: 4px; }
.pkg.on { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); background: color-mix(in srgb, var(--green) 6%, var(--surface)); }

/* Quote box */
.quote { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--shadow-lg); }
:root[data-theme="dark"] .quote, .quote { --qtxt: #fff; }
.quote .ql { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: .9rem; opacity: .92; border-bottom: 1px solid rgba(255,255,255,.12); }
.quote .qt { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-size: 1.6rem; font-weight: 800; }
.quote .qt small { font-size: .85rem; font-weight: 500; opacity: .8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .quote { background: linear-gradient(135deg, #1d3461, #2a4a85); } }
:root[data-theme="dark"] .quote { background: linear-gradient(135deg, #1d3461, #2a4a85); }

/* Maps */
.map { height: 320px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; z-index: 0; }
.map.tall { height: 460px; }
.map.full { height: calc(100vh - 140px); }
.mapbar { display: flex; gap: 8px; margin-bottom: 10px; }
.mapbar input { margin: 0; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.pin.o { background: var(--green); } .pin.d { background: #e0503a; } .pin.a { background: #1d3461; } .pin.t { background: #2f7de1; }
.truck { font-size: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid var(--surface); }
.timeline li .tt { font-weight: 600; }
.timeline li .td { color: var(--muted); font-size: .82rem; }

/* Progress of states */
.progress { display: flex; gap: 4px; margin: 10px 0 16px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress span.on { background: var(--green); }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 1.7rem; font-weight: 800; color: var(--navy); }
.stat .l { color: var(--muted); font-size: .85rem; font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }

/* Dialog */
dialog { border: 0; border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: 90vh; }
dialog::backdrop { background: rgba(10, 20, 40, .45); backdrop-filter: blur(3px); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: transform .25s; z-index: 9999; max-width: calc(100vw - 32px); }
#toast.on { transform: translateX(-50%) translateY(0); }

/* QR */
.qrbox { display: grid; place-items: center; background: #fff; padding: 14px; border-radius: 14px; width: max-content; margin: 10px auto; }
.scanner { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 1; max-width: 420px; margin: 0 auto 12px; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Mobile app shell (m/ y app/) */
.top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.top img { height: 34px; }
.top h1 { font-size: 1.05rem; flex: 1; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { border: 0; background: var(--surface-2); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; cursor: pointer; }
.shell { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.on { display: block; animation: fade .2s ease; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: .72rem; font-weight: 600; padding: 6px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button .ic { font-size: 1.35rem; }
.tabbar button.on { color: var(--green); }
.hero { text-align: center; padding: 16px 0 8px; }
.hero img { width: min(300px, 80%); }
.logo-login { display: block; width: min(320px, 85%); margin: 24px auto 16px; border-radius: 16px; }
.hello { font-size: 1.3rem; font-weight: 800; margin: 4px 0 12px; }

/* Desktop shell (admin/) */
.desk { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side img { width: 100%; border-radius: 12px; margin-bottom: 14px; }
.side button { text-align: left; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 11px 14px; border-radius: 12px; cursor: pointer; display: flex; gap: 10px; }
.side button:hover { background: var(--surface-2); color: var(--text); }
.side button.on { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green-2); }
.main { padding: 24px 28px; min-width: 0; }
.main-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.main-head h1 { font-size: 1.5rem; flex: 1; margin: 0; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .desk { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
  .side img, .side .spacer { display: none; }
  .side button { white-space: nowrap; }
  .main { padding: 16px; }
}

@media print {
  body { background: #fff; }
  .noprint { display: none !important; }
}
