:root {
  --brand: #1428a0; --brand-2: #2f4ad6; --brand-soft: #eef1fd;
  --bg: #f4f6fb; --card: #ffffff; --text: #141a2e; --muted: #667089; --line: #e3e7f0;
  --ok: #0f9d58; --ok-soft: #e6f6ee; --bad: #d93025; --bad-soft: #fde8e7;
  --warn: #c77700; --warn-soft: #fff4e0; --info: #1a73e8; --info-soft: #e8f0fe;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,64,.06), 0 6px 24px rgba(16,24,64,.06);
  --sidebar: #0d1640;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
code { background: var(--brand-soft); color: var(--brand); padding: 1px 6px; border-radius: 6px; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 10px; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-ok { color: var(--ok); font-weight: 600; } .t-bad { color: var(--bad); font-weight: 600; }
.ic { flex: none; vertical-align: -3px; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 248px; background: var(--sidebar); color: #c9d0ec; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; flex: none; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; }
.brand strong { color: #fff; display: block; font-size: 15px; }
.brand span { font-size: 12px; opacity: .7; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #3d5afe, var(--brand)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; box-shadow: 0 4px 14px rgba(61,90,254,.45); }
.logo.big { width: 56px; height: 56px; font-size: 26px; border-radius: 14px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
nav a { display: flex; gap: 11px; align-items: center; padding: 9px 12px; border-radius: 10px; font-weight: 500; transition: background .15s; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(93,121,255,.22); color: #fff; box-shadow: inset 3px 0 0 #7b93ff; }
.nav-label { text-transform: uppercase; font-size: 11px; letter-spacing: .08em; opacity: .5; padding: 16px 12px 6px; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.me-info { flex: 1; min-width: 0; } .me-info strong { color: #fff; display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info span { font-size: 12px; opacity: .7; }
.me a { opacity: .7; padding: 4px; } .me a:hover { opacity: 1; color: #fff; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2a3a8f; color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { flex: 1; min-width: 0; padding: 0 32px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; height: 60px; color: var(--muted); }
.crumb { flex: 1; } .crumb strong { color: var(--text); }
.ver { font-size: 12px; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; border: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin: 8px 0 22px; }
.hero p { color: var(--muted); max-width: 640px; }
.env-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: #fff; border: 1px solid var(--line); color: var(--muted); font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-bottom: 20px; }
.mod-card { display: flex; flex-direction: column; gap: 8px; margin: 0; transition: transform .15s, box-shadow .15s; }
.mod-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(20,40,160,.13); border-color: #c8d0f5; }
.mod-card h3 { margin: 6px 0 0; } .mod-card p { color: var(--muted); font-size: 13px; flex: 1; }
.mod-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12.5px; }
.mod-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.c-precios { background: #eef1fd; color: #1428a0; } .c-stock { background: #e6f6ee; color: #0f8a4f; }
.c-feedback { background: #f3e8fd; color: #7b2fd0; } .c-pickup { background: #fff4e0; color: #b86b00; }
.c-shipment { background: #e3f4fb; color: #0b7aa6; }
.tag { background: var(--brand-soft); color: var(--brand); padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.big { font-size: 13px; padding: 6px 14px; }
.page-head { margin: 8px 0 22px; } .page-head p { color: var(--muted); }
.page-head.with-icon { display: flex; gap: 16px; align-items: center; }
.page-head.with-icon > div:nth-child(2) { flex: 1; }
.link { color: var(--brand-2); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }

/* steps */
.step { display: flex; gap: 16px; }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.step-body { flex: 1; min-width: 0; }
.dropzone { border: 2px dashed #c3cbe6; border-radius: 12px; padding: 34px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer; background: #fafbff; transition: all .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand-2); background: var(--brand-soft); }
.dropzone.busy { opacity: .7; pointer-events: none; }
.dz-ic { color: var(--brand-2); }
.dz-file { margin-top: 8px; min-height: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: #fbfcfe; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-size: 22px; }
.stat.ok strong { color: var(--ok); } .stat.bad strong { color: var(--bad); } .stat.warn strong { color: var(--warn); } .stat.info strong { color: var(--brand); }
.notice { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.notice summary { cursor: pointer; font-weight: 600; }
.notice ul { margin: 8px 0 0; padding-left: 20px; max-height: 220px; overflow: auto; }
.notice.bad { background: var(--bad-soft); color: #8c1d16; } .notice.warn { background: var(--warn-soft); color: #7a4a00; }

.progress { height: 10px; background: #e9ecf5; border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-2), #6a86ff); transition: width .4s; }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 460px; }
.table-wrap.tall { max-height: 520px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: #f7f8fc; text-align: left; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 12px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbff; }
.row-bad td { background: #fff7f6; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
form.inline { display: inline; }

.status { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; text-transform: capitalize; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.s-completado { background: var(--ok-soft); color: var(--ok); }
.s-con_errores { background: var(--bad-soft); color: var(--bad); }
.s-en_proceso { background: var(--info-soft); color: var(--info); }
.s-cancelado { background: #eef0f5; color: #555; }

/* side panel */
.cols { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 10px; }
.req, .opt { font-size: 11px; margin-left: 6px; font-weight: 600; }
.req { color: var(--bad); } .opt { color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.mini-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mini-hist li { display: flex; gap: 10px; align-items: center; } .mini-hist li > div { flex: 1; min-width: 0; }
.mini-hist .trunc { max-width: 180px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(20,40,160,.25); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: #b9c3e8; background: var(--brand-soft); }
.btn.danger { background: #fff; border-color: #f3c3bf; color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.actions-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.narrow { max-width: 440px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid #d4d9e6; border-radius: 10px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,74,214,.15); }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.flash.error { background: var(--bad-soft); color: #8c1d16; } .flash.ok { background: var(--ok-soft); color: #0b6b3d; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(10,16,48,.45); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal-box { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-box.wide { max-width: 860px; }
.modal-box h2 { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.modal-box p { margin-bottom: 8px; }
pre.json { background: #0d1640; color: #d6defd; padding: 16px; border-radius: 10px; max-height: 60vh; overflow: auto; font-size: 12.5px; margin: 0; white-space: pre-wrap; word-break: break-word; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #c3cbe6; border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-body { background: radial-gradient(1200px 600px at 10% 0%, #2a3fc4 0%, #0d1640 55%, #080e2c 100%); min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; max-width: 920px; width: 100%; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-hero { color: #dfe5ff; padding: 48px 44px; background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 14px; border: 1px solid rgba(255,255,255,.08); border-right: 0; border-radius: 22px 0 0 22px; }
.login-hero h1 { color: #fff; font-size: 30px; margin-top: 10px; }
.login-hero ul { padding-left: 18px; margin: 6px 0 auto; display: flex; flex-direction: column; gap: 6px; }
.login-hero small { opacity: .6; margin-top: 30px; }
.login-card { background: #fff; padding: 48px 40px; display: flex; flex-direction: column; gap: 16px; }
.login-card h2 { font-size: 24px; }

@media (max-width: 1100px) { .grid-main, .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .content { padding: 0 16px 32px; }
  .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; }
  .page-head.with-icon { flex-wrap: wrap; }
  .step { flex-direction: column; gap: 10px; }
}

/* --- adiciones versión serverless --- */
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #0d1640; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: tin .2s ease-out; }
.toast.error { background: var(--bad); } .toast.ok { background: #0b7a45; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.pw-rules { font-size: 12.5px; color: var(--muted); margin: -6px 0 0; padding-left: 18px; }
.login-card .link-btn { background: none; border: 0; color: var(--brand-2); cursor: pointer; font: inherit; padding: 0; text-align: left; }
