/* Panel de rm-entregas: mismo aspecto que RM-Envíos (colores, letra, cabecera y componentes),
   con menú lateral en escritorio y desplegable en el móvil. Sin dependencias ni JS. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #16202e;
  --ink-2: #4a5669;
  --muted: #7a8699;
  --line: #e2e7ef;
  --navy: #10213f;
  --blue: #1f5eff;
  --blue-soft: #e8efff;
  --green: #11875d;
  --green-soft: #e3f5ec;
  --amber: #b86e00;
  --amber-soft: #fff3de;
  --red: #c23a3a;
  --red-soft: #fde8e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 33, 63, .06), 0 2px 8px rgba(16, 33, 63, .04);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side: 224px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 1.5rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: #eef1f6; padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
p { margin: 0 0 .75rem; }
ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; }

/* ------------------------------------------------------------ barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--navy); color: #fff;
}
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--blue); color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: .02em;
}
.topbar-space { flex: 1; }
.who { display: flex; align-items: center; gap: 12px; }
.who form { margin: 0; }
.who-name { color: #fff; font-weight: 500; }
.who-name:hover { color: #fff; }
.role { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.15); margin-left: 4px; color: #fff; }
.topbar .btn-link { color: #c9d3e6; }

/* ------------------------------------------------------- menú lateral (escritorio) */
.layout {
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - 56px);
  /* El fondo blanco del menú llega hasta abajo aunque la página sea larga. */
  background: linear-gradient(90deg, var(--surface) var(--side), var(--bg) var(--side));
}
.side {
  position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line);
}
.side-group { margin: 14px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.side-group:first-child { margin-top: 0; }
.side a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.side a:hover { background: #f0f3f8; text-decoration: none; color: var(--ink); }
.side a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.side svg { flex: none; width: 18px; height: 18px; }

/* ---------------------------------------------------------- menú del móvil */
.mmenu { display: none; position: relative; margin-left: auto; }
.mmenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.1); color: #fff; font-weight: 600;
}
.mmenu summary::-webkit-details-marker { display: none; }
.mmenu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 33, 63, .18); padding: 8px; display: grid; gap: 2px;
}
.mmenu-panel a { padding: 10px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.mmenu-panel a.active { background: var(--blue-soft); color: var(--blue); }
.mmenu-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 12px 4px; }
.mmenu-foot form { margin: 0; }

/* ------------------------------------------------------------------ página */
.page { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 24px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------------------- controles */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #f0f3f8; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #164de0; }
.btn-danger { color: var(--red); border-color: #f1c6c6; }
.btn-danger:hover { background: var(--red-soft); }
.btn-small { padding: 6px 12px; font-size: .82rem; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

input, select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  min-height: 40px;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(31, 94, 255, .25); outline-offset: 1px; border-color: var(--blue);
}
label { display: grid; gap: 6px; font-weight: 500; font-size: .9rem; color: var(--ink-2); margin-bottom: 12px; }
form > button, form > .btn { margin-top: 4px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 0 20px; }
legend { font-weight: 500; font-size: .9rem; color: var(--ink-2); padding: 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.add-title { margin-top: 20px; }
.grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: end; }
.row label { flex: 1 1 140px; }
.row > button { margin-bottom: 12px; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; background: var(--amber-soft); color: var(--amber); }
.alert ul { margin-bottom: 0; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--green-soft); color: var(--green); }

/* --------------------------------------------------------------- tarjetas */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .panel > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 16px; }
.cards > .card { margin: 0; }
main > h2 { margin-top: 24px; }

/* Cifras del Inicio */
.stat-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.stat-sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ------------------------------------------------------------------ tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
td form { margin: 0; }
.card > table:last-child, .panel > table:last-child, .table-wrap:last-child { margin-bottom: -6px; }
/* Tablas de clave → valor (dos columnas, la primera es th) */
.kv th { width: 34%; text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--ink-2); font-weight: 600; vertical-align: top; }

/* ---------------------------------------------------------------- píldoras */
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-error { background: var(--red-soft); color: var(--red); }
.pill-info { background: var(--blue-soft); color: var(--blue); }

/* Fechas de ejemplo del Inicio */
.dates { display: grid; gap: 4px; }
.dates strong, .nowrap { white-space: nowrap; }
.dates strong { font-size: 1.05rem; }

/* ------------------------------------------------------------------ login */
.auth-page { background: linear-gradient(160deg, var(--navy) 0%, #1b3566 100%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px; display: grid; gap: 4px; box-shadow: 0 20px 50px rgba(0,0,0,.25); border: 0; }
.auth-card .brand { color: var(--ink); margin-bottom: 8px; }
.auth-card h1 { margin-bottom: 8px; }
.auth-card .btn { width: 100%; }
.qr svg { width: 200px; height: 200px; }

/* ------------------------------------------------------------------ móvil */
@media (max-width: 900px) {
  .layout { display: block; background: none; }
  .side { display: none; }
  .mmenu { display: block; }
  .who { display: none; }
  .topbar { padding: 0 12px; }
  .page { padding: 16px 12px 48px; }
  .card, .panel { padding: 16px; }
  /* Las tablas anchas se desplazan dentro de su tarjeta, no estiran la página. */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .kv { display: table; }
  .kv th { width: 40%; }
  th, td { padding: 8px 6px; }
  /* Cabeceras en una línea: si no, las columnas que quedan fuera de la vista dejan un hueco. */
  th { white-space: nowrap; }
}
