/* =========================================================================
   DeCA · Hoja de estilos
   Colores corporativos IndosGestión: ajústalos en este bloque :root
   (son los únicos valores que hay que tocar para cambiar la marca).
   ========================================================================= */
:root {
  --brand-primary:      #1d3d6e;  /* azul corporativo (principal)      */
  --brand-primary-dark: #142b4f;  /* hover / fondos oscuros            */
  --brand-accent:       #2bb3c0;  /* acento                            */
  --brand-accent-soft:  #e6f6f8;

  --text:        #1f2933;
  --text-muted:  #5f6b7a;
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #d9dee5;
  --focus:       #2bb3c0;

  --error-bg:    #fdecec;  --error-fg:   #a12222;
  --success-bg:  #e8f6ee;  --success-fg: #1c6b3c;
  --info-bg:     #e8f0fb;  --info-fg:    #1d3d6e;

  --radius: 10px;
  --shadow: 0 10px 30px rgba(20, 43, 79, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--text-muted); }

/* ---------- Layout de autenticación ------------------------------------ */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth--single { grid-template-columns: 1fr; }

.auth__brand {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 3rem 4rem;
}
.auth__brand-inner { position: relative; z-index: 1; max-width: 420px; }
.auth__brand-logo {
  height: 64px;
  width: auto;
  background: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 2.5rem;
}
.auth__brand-title { font-size: 2.1rem; font-weight: 400; margin-bottom: 1rem; }
.auth__brand-title strong { font-weight: 800; color: var(--brand-accent); letter-spacing: .02em; }
.auth__brand-text { opacity: .8; margin: 0; }
.auth__brand-shape {
  position: absolute;
  right: -160px; bottom: -160px;
  width: 460px; height: 460px;
  border-radius: 50%;
  border: 60px solid rgba(43, 179, 192, .18);
}

.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* ---------- Tarjeta / formulario ---------------------------------------- */
.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem 1.5rem;
  border-top: 4px solid var(--brand-accent);
}
.card__logo { display: none; height: 44px; width: auto; margin-bottom: 1.5rem; }
.auth--single .card__logo { display: block; }
.card__title { font-size: 1.5rem; color: var(--brand-primary); }
.card__subtitle { color: var(--text-muted); margin: 0 0 1.5rem; }
.card__foot {
  margin: 1.75rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
}

.form { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field input {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--brand-accent-soft);
}
.field__pwd { position: relative; }
.field__pwd input { padding-right: 4.5rem; }
.field__toggle {
  position: absolute; top: 50%; right: .4rem; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer;
  color: var(--brand-primary); font: inherit; font-size: .85rem; font-weight: 600;
  padding: .35rem .5rem; border-radius: 6px;
}
.field__toggle:focus-visible { outline: 2px solid var(--focus); }
.field__hint { margin: 0; font-size: .8rem; color: var(--text-muted); }

/* ---------- Botones ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.2rem;
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:focus-visible { outline: 3px solid var(--brand-accent-soft); outline-offset: 1px; }
.btn--primary { background: var(--brand-primary); color: #fff; }
.btn--primary:hover { background: var(--brand-primary-dark); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); padding: .45rem .9rem; }
.btn--ghost:hover { background: rgba(255,255,255,.1); }
.btn--link { background: none; border: 0; color: var(--brand-primary); padding: 0; font-size: .85rem; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alertas ----------------------------------------------------- */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert--error   { background: var(--error-bg);   color: var(--error-fg); }
.alert--success { background: var(--success-bg); color: var(--success-fg); }
.alert--info    { background: var(--info-bg);    color: var(--info-fg); }

/* ---------- Aplicación (tras login) ------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.5rem;
  background: var(--brand-primary); color: #fff;
}
.topbar__brand { display: flex; align-items: center; gap: .75rem; }
.topbar__logo { height: 34px; width: auto; background: #fff; padding: 4px 8px; border-radius: 6px; }
.topbar__app { font-weight: 800; letter-spacing: .04em; color: var(--brand-accent); }
.topbar__user { display: flex; align-items: center; gap: .6rem; }
.topbar__user form { margin: 0; }
.topbar__name { opacity: .9; margin-right: .5rem; }

.app { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.app h1 { color: var(--brand-primary); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-top: 2rem; }
.tile {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(20,43,79,.06); border-left: 4px solid var(--brand-accent);
}
.tile h2 { font-size: 1.05rem; }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { display: none; }
  .card__logo { display: block; }
  .topbar__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================================
   Módulos internos: navegación, tablas, filtros, paneles, badges
   ========================================================================= */
:root {
  --warning-bg: #fff6e0; --warning-fg: #7a5200;
  --danger: #b42323; --danger-dark: #8f1b1b;
}
.topbar__home { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.topbar__brand { gap: 1.5rem; flex-wrap: wrap; }
.topbar__name small { display: block; font-size: .75rem; opacity: .75; }
.topnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topnav__link {
  color: rgba(255,255,255,.85); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: .45rem .8rem; border-radius: 6px;
}
.topnav__link:hover { background: rgba(255,255,255,.1); color: #fff; }
.topnav__link.is-active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 -2px 0 var(--brand-accent); }

.page-head { margin-bottom: 1.25rem; }
.page-head--row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head p { margin: .25rem 0 0; }

.panel {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 8px rgba(20,43,79,.06); margin-bottom: 1.25rem;
}
.panel h2 { font-size: 1.05rem; color: var(--brand-primary); margin-bottom: 1rem; }
.panel hr, .app hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }

.filters { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filters label { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--text-muted); }
.filters input, .filters select, .form select {
  padding: .55rem .7rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.filters input[type="search"] { min-width: 240px; flex: 1 1 240px; max-width: 420px; }
.filters input:focus, .filters select:focus, .form select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--brand-accent-soft); }

.form--inline { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.field--grow { flex: 1 1 280px; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(20,43,79,.06); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: #f8fafc; padding: .7rem .9rem; border-bottom: 1px solid var(--border);
}
.table td { padding: .65rem .9rem; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.table tbody tr:hover { background: #fafbfd; }
.table__actions { text-align: right; white-space: nowrap; }
.table--dense td { padding: .5rem .75rem; font-size: .86rem; }
.table code, .dl code { font-size: .85em; background: #f1f4f8; padding: .1rem .35rem; border-radius: 4px; }
.cell-json code { display: block; max-width: 360px; white-space: pre-wrap; word-break: break-all; background: transparent; padding: 0; color: var(--text-muted); }
.nowrap { white-space: nowrap; }

.pager { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.pager__info { color: var(--text-muted); font-size: .85rem; margin: 1rem 0 0; }
.pager .pager__info { margin: 0 auto 0 0; }

.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .76rem; font-weight: 700; letter-spacing: .02em; background: #eef1f5; color: var(--text-muted);
}
.badge--superadmin { background: var(--brand-primary); color: #fff; }
.badge--admin      { background: var(--brand-accent-soft); color: #136b74; }
.badge--transportista  { background: #eef3ea; color: #3f6a2a; }
.badge--conductor  { background: #fff1d6; color: #7a5200; }
.badge--none       { background: #f2f2f2; color: #7a7a7a; }
.badge--ok         { background: var(--success-bg); color: var(--success-fg); }
.badge--fallo      { background: var(--warning-bg); color: var(--warning-fg); }
.badge--denegado   { background: var(--error-bg); color: var(--error-fg); }

.btn--small { padding: .35rem .7rem; font-size: .85rem; background: #eef1f5; color: var(--brand-primary); }
.btn--small:hover { background: #e2e7ee; }
.btn--small.btn--primary { background: var(--brand-primary); color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-dark); }
.btn--small.btn--danger { background: var(--error-bg); color: var(--danger); }

.alert--warning { background: var(--warning-bg); color: var(--warning-fg); }
.secret { border: 1px dashed currentColor; }
.secret__value { display: inline-block; font-size: 1.15rem; padding: .25rem .6rem; margin: .25rem .5rem; background: #fff; border-radius: 6px; user-select: all; }
.secret p { margin: .5rem 0 0; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
.dl dt { color: var(--text-muted); font-size: .88rem; }
.dl dd { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid #eef1f5; }
.list__item form { margin: 0; }

.tile--link { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.tile--link:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile--link h2 { color: var(--brand-primary); }

.empty { text-align: center; padding: 4rem 1rem; }
.empty h1 { color: var(--brand-primary); }

/* =========================================================================
   Menú lateral (escritorio fijo · móvil desplegable)
   ========================================================================= */
:root { --sidebar-w: 248px; }
.icon { width: 20px; height: 20px; flex: 0 0 20px; }

.page-app { background: var(--bg); }
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
}
.sidebar__brand { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar__home { display: inline-block; }
.sidebar__logo { height: 40px; width: auto; background: #fff; padding: 5px 10px; border-radius: 8px; display: block; }
.sidebar__app {
  display: block; margin-top: .75rem; font-weight: 800; letter-spacing: .08em; font-size: .8rem;
  text-transform: uppercase; color: var(--brand-accent);
}

.sidenav { display: flex; flex-direction: column; gap: 2px; padding: 1rem .75rem; flex: 1; }
.sidenav__link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .85rem; border-radius: 8px;
  color: rgba(255,255,255,.82); text-decoration: none; font-weight: 600; font-size: .94rem;
  transition: background .15s, color .15s;
}
.sidenav__link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidenav__link:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 1px; }
.sidenav__link.is-active {
  background: rgba(255,255,255,.14); color: #fff;
  box-shadow: inset 3px 0 0 var(--brand-accent);
}
.sidenav__link.is-active .icon { color: var(--brand-accent); }
.sidenav__link--small { font-size: .86rem; padding: .5rem .85rem; font-weight: 500; }
.sidenav__button { width: 100%; background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; }

.sidebar__user { padding: .75rem; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar__user form { margin: 0; }
.sidebar__who { display: flex; align-items: center; gap: .7rem; padding: .5rem .5rem .75rem; }
.avatar {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: var(--brand-accent); color: var(--brand-primary-dark);
}
.sidebar__name { font-size: .88rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.sidebar__name small { display: block; opacity: .7; font-size: .76rem; }

.main { min-width: 0; display: flex; flex-direction: column; }
.main .app { width: 100%; max-width: 1200px; padding: 2rem 2rem 3rem; }
.mobilebar, .sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--sidebar-w));
    transform: translateX(-100%); transition: transform .22s ease; z-index: 40;
    visibility: hidden;
  }
  .shell.is-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(15,25,40,.45); z-index: 30; }
  .mobilebar {
    display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 20;
    padding: .6rem 1rem; background: var(--brand-primary); color: #fff;
  }
  .mobilebar__toggle {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
    background: rgba(255,255,255,.1); color: #fff; border: 0; cursor: pointer;
  }
  .mobilebar__title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobilebar__logo { height: 30px; width: auto; background: #fff; padding: 3px 7px; border-radius: 6px; }
  .main .app { padding: 1.25rem 1rem 2rem; }
  body.menu-open { overflow: hidden; }
}

/* Tipos de cambio: edición en línea */
.inline-edit { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-edit input[type="text"] {
  flex: 1 1 260px; padding: .45rem .65rem; font: inherit; border: 1px solid var(--focus); border-radius: 8px;
  box-shadow: 0 0 0 3px var(--brand-accent-soft);
}
.row-inactive td { color: var(--text-muted); }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: 0 2px 8px rgba(20,43,79,.06); min-width: 140px; }
.stat strong { display: block; font-size: 1.4rem; color: var(--brand-primary); }
.stat span { font-size: .8rem; color: var(--text-muted); }
form.inline { display: inline-block; margin: 0 0 0 .25rem; }

/* Formulario de alta en dos columnas */
.form--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 1.5rem; }
.field--full { grid-column: 1 / -1; }
.form__actions { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.choice { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.choice legend { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; padding: 0; }
.choice__item {
  display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.choice__item:has(input:checked) { border-color: var(--brand-accent); box-shadow: 0 0 0 3px var(--brand-accent-soft); }
.choice__item input { margin-top: .2rem; accent-color: var(--brand-primary); }
.choice__item small { display: block; margin-top: .15rem; }
@media (max-width: 640px) { .form--grid { grid-template-columns: 1fr; } }

/* =========================================================================
   Documentos DeCA
   ========================================================================= */
.badge--emitido { background: var(--info-bg); color: var(--info-fg); }
.badge--ruta    { background: var(--brand-accent-soft); color: #136b74; }
.th-sort { color: inherit; text-decoration: none; display: inline-flex; gap: .3rem; align-items: center; white-space: nowrap; }
.th-sort span { opacity: .45; font-size: .75em; }
.th-sort:hover, .th-sort.is-active { color: var(--brand-primary); }
.th-sort.is-active span { opacity: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--danger); }
.break { overflow-wrap: anywhere; }

.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field__error { margin: 0; font-size: .8rem; color: var(--danger); }
.field textarea, .field select {
  width: 100%; padding: .6rem .75rem; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.field input[readonly] { background: #f1f4f8; color: var(--text-muted); }
.panel--highlight { border-left: 4px solid var(--brand-accent); }

.deca-form .panel h2 small { font-weight: 400; font-size: .8rem; }
.merc { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1rem .75rem; margin: 0 0 1rem; }
.merc legend { font-weight: 700; font-size: .85rem; color: var(--brand-primary); padding: 0 .35rem; }
.merc__del { position: absolute; top: -.95rem; right: .75rem; box-shadow: 0 0 0 4px var(--surface); }
.merc__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem 1rem; }
.merc__wide { grid-column: 1 / -1; }
.merc__adr { margin-top: .75rem; padding: .85rem; background: var(--warning-bg); border-radius: 8px; }
.check { display: inline-flex; align-items: center; gap: .5rem; margin-top: .75rem; font-weight: 600; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-primary); }
.form__actions--sticky {
  position: sticky; bottom: 0; z-index: 5; background: rgba(244,246,249,.94); backdrop-filter: blur(4px);
  padding: .9rem 0; margin-top: .5rem;
}

.deca-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.deca-side { position: sticky; top: 1rem; }
.table-wrap--flat { box-shadow: none; border: 1px solid var(--border); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { position: relative; padding: 0 0 1rem 1.1rem; border-left: 2px solid var(--border); margin-left: .35rem; }
.timeline__item::before {
  content: ""; position: absolute; left: -7px; top: .3rem; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border);
}
.timeline__item.is-current::before { background: var(--brand-accent); border-color: var(--brand-accent); }
.timeline__item:last-child { border-left-color: transparent; }
.timeline__head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.timeline__head a { color: var(--brand-primary); text-decoration: none; }
.timeline__meta { margin: .2rem 0 0; font-size: .8rem; color: var(--text-muted); }
.timeline__motivo { margin: .35rem 0 0; font-size: .86rem; background: #f8fafc; padding: .4rem .6rem; border-radius: 6px; }
.diff { margin-top: .4rem; font-size: .82rem; }
.diff summary { cursor: pointer; color: var(--brand-primary); font-weight: 600; }
.diff__table { width: 100%; border-collapse: collapse; margin-top: .4rem; }
.diff__table th { text-align: left; font-weight: 600; color: var(--text-muted); padding: .3rem .4rem .3rem 0; vertical-align: top; width: 38%; }
.diff__table td { padding: .3rem 0; }
.diff__table del { display: block; color: var(--danger); background: var(--error-bg); text-decoration: line-through; padding: 0 .3rem; border-radius: 4px; }
.diff__table ins { display: block; color: var(--success-fg); background: var(--success-bg); text-decoration: none; padding: 0 .3rem; border-radius: 4px; margin-top: 2px; }

@media (max-width: 1100px) {
  .deca-layout { grid-template-columns: 1fr; }
  .deca-side { position: static; }
}
@media (max-width: 640px) {
  .merc__grid { grid-template-columns: 1fr; }
}
[hidden] { display: none !important; }
.table a:not(.btn) { color: var(--brand-primary); text-decoration: none; }
.table a:not(.btn):hover { text-decoration: underline; }

/* ---- DeCA: borrador, acciones, consignatario ---- */
.badge--borrador { background: #fff1d6; color: #7a5200; border: 1px dashed #d9a640; }
.page-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.consig { border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; margin: 0 0 1rem; display: grid; gap: .8rem; background: #fafbfd; }
.consig legend { font-weight: 700; font-size: .85rem; padding: 0 .35rem; color: var(--brand-primary); }

/* ---- Consulta pública por QR ---- */
.page-qr { background: var(--bg); }
.qr { max-width: 520px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.qr__brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; color: var(--text-muted); font-weight: 600; font-size: .9rem; }
.qr__logo { height: 34px; width: auto; }
.qr__banner { padding: .9rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .95rem; }
.qr__banner a { color: inherit; font-weight: 700; }
.qr__banner--ok     { background: var(--success-bg); color: var(--success-fg); border-left: 5px solid var(--success-fg); }
.qr__banner--warn   { background: var(--warning-bg); color: var(--warning-fg); border-left: 5px solid var(--warning-fg); }
.qr__banner--danger { background: var(--error-bg); color: var(--error-fg); border-left: 5px solid var(--error-fg); }
.qr__card { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.qr__card--error { text-align: center; margin-top: 3rem; }
.qr__label { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.qr__code { font-size: 1.8rem; margin: .1rem 0 1rem; letter-spacing: .02em; }
.qr__dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0 0 1.25rem; font-size: .92rem; }
.qr__dl dt { color: var(--text-muted); }
.qr__dl dd { margin: 0; overflow-wrap: anywhere; }
.qr__prev { text-align: center; margin: 1rem 0 0; }
.qr__prev a { color: var(--brand-primary); }
.qr__foot { margin-top: 1.25rem; font-size: .72rem; color: var(--text-muted); text-align: center; overflow-wrap: anywhere; }

/* ---- Buscador de transportistas (diálogo) y bloques del formulario DeCA ---- */
.transp-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.transp-pick__estado { margin: 0; flex: 1 1 260px; color: var(--text-muted); font-size: .9rem; }
.cond-alta { display: flex; flex-direction: column; gap: .1rem; }
.cond-alta .check { margin-top: .35rem; }
.transp-pick .btn .icon { width: 1rem; height: 1rem; margin-right: .3rem; vertical-align: -.15em; }

/* Ventana de búsqueda */
.dlg { width: min(680px, calc(100vw - 32px)); max-height: min(82vh, 680px); padding: 0; border: 0;
       border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 35, .28); background: var(--surface); color: var(--text);
       overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: dlg-in .16s ease-out; }
.dlg::backdrop { background: rgba(15, 23, 35, .5); backdrop-filter: blur(2px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.5rem .9rem; }
.dlg__head h2 { margin: 0; font-size: 1.25rem; }
.dlg__sub { margin: .2rem 0 0; color: var(--text-muted); font-size: .88rem; }
.dlg__close { flex: none; width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%; background: var(--bg);
              color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; transition: background .15s, color .15s; }
.dlg__close:hover, .dlg__close:focus-visible { background: var(--border); color: var(--text); outline: none; }
.dlg__search { position: relative; margin: 0 1.5rem; }
.dlg__search .icon { position: absolute; left: 1rem; top: 50%; width: 1.25rem; height: 1.25rem; transform: translateY(-50%);
                     color: var(--text-muted); pointer-events: none; }
.dlg__q { display: block; width: 100%; padding: .95rem 1rem .95rem 3rem; font: inherit; font-size: 1.05rem; color: var(--text);
          background: var(--bg); border: 2px solid var(--border); border-radius: 12px; transition: border-color .15s, box-shadow .15s, background .15s; }
.dlg__q::placeholder { color: #8a94a3; }
.dlg__q:focus { outline: none; background: #fff; border-color: var(--focus); box-shadow: 0 0 0 4px var(--brand-accent-soft); }
.dlg.is-loading .dlg__search::after { content: ""; position: absolute; right: 1rem; top: 50%; width: 1.1rem; height: 1.1rem; margin-top: -.55rem;
                                      border: 2px solid var(--border); border-top-color: var(--focus); border-radius: 50%; animation: dlg-spin .7s linear infinite; }
@keyframes dlg-spin { to { transform: rotate(360deg); } }
.dlg__msg { margin: .75rem 1.5rem .35rem; min-height: 1.2em; font-size: .85rem; color: var(--text-muted); }
.dlg__list { list-style: none; margin: 0; padding: 0 .75rem .75rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dlg__list li + li { border-top: 1px solid #eef0f3; }
.dlg__item { display: flex; align-items: center; gap: .85rem; width: 100%; text-align: left; padding: .75rem .75rem;
             border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; cursor: pointer; transition: background .12s; }
.dlg__item:hover, .dlg__item:focus-visible { background: var(--brand-accent-soft); outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.dlg__ini { flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%;
            background: var(--brand-primary); color: #fff; font-weight: 700; font-size: 1rem; }
.dlg__txt { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1 1 auto; }
.dlg__txt strong { font-size: 1rem; overflow-wrap: anywhere; }
.dlg__meta { color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.dlg__chip { flex: none; padding: .2rem .6rem; border-radius: 999px; background: var(--bg); color: var(--text-muted);
             font-size: .78rem; white-space: nowrap; }
.dlg__foot { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; padding: .7rem 1.5rem; border-top: 1px solid var(--border);
             background: var(--bg); color: var(--text-muted); font-size: .78rem; }
.dlg__foot kbd { display: inline-block; min-width: 1.4em; margin-right: .2rem; padding: .05rem .35rem; border: 1px solid var(--border);
                 border-bottom-width: 2px; border-radius: 5px; background: #fff; font: inherit; font-size: .72rem; text-align: center; }
@media (max-width: 560px) {
  .dlg { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  .dlg__head { padding: 1rem 1rem .75rem; }
  .dlg__search { margin: 0 1rem; }
  .dlg__msg { margin: .6rem 1rem .3rem; }
  .dlg__foot { display: none; }
  .dlg__chip { display: none; }
}
.row-edit td { background: var(--bg); }
.credenciales code { font-size: 1rem; padding: .1rem .35rem; background: var(--surface); border-radius: 4px; user-select: all; }

/* ---- Página del conductor (móvil primero) ---- */
.cond-page { max-width: 760px; margin: 0 auto; }
.cond-entregas { display: grid; gap: .75rem; }
.cond-entrega { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; background: var(--surface); }
.cond-entrega legend { font-weight: 700; padding: 0 .25rem; }
.cond-entrega .form--grid { margin-top: .25rem; }

/* ---- Botón con icono (p. ej. configuración de la cuenta de correo) ---- */
.btn--icon { display: inline-flex; align-items: center; gap: .4rem; }
.btn--icon .icon { width: 18px; height: 18px; }

/* ---- Formularios en rejilla: cada campo arriba de su celda y acciones a todo el ancho ---- */
.field { align-content: start; }
.form--grid { align-items: start; }
.form--grid > .form__actions { grid-column: 1 / -1; }
.form--grid > .check { align-self: center; margin-top: 0; }
.form--grid > .check.field--full { margin-top: .25rem; }
.field .check { margin-top: .35rem; font-weight: 500; }

/* ---- Notificaciones › Plantillas ---- */
.plantillas { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.plantillas__lista h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: .75rem 0 .35rem; }
.plantillas__lista h2:first-child { margin-top: 0; }
.plantillas__lista ul { list-style: none; margin: 0; padding: 0; }
.plantillas__lista a { display: block; padding: .5rem .65rem; border-radius: 8px; color: inherit; text-decoration: none; font-size: .92rem; }
.plantillas__lista a:hover { background: var(--bg); }
.plantillas__lista a.is-active { background: var(--brand-accent-soft); font-weight: 600; }
.plantilla-vista { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; background: #fff; overflow-wrap: anywhere; }
.plantilla-vista--sms { max-width: 360px; background: #eef3d9; border-radius: 14px 14px 14px 4px; font-size: .95rem; }
.dl--compact dt { font-weight: 400; }
.form__actions--start { justify-content: flex-start; flex-wrap: wrap; }
@media (max-width: 900px) { .plantillas { grid-template-columns: 1fr; } }
.sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---- Ventana de confirmación (sustituye al confirm() del navegador) ---- */
.confirm {
  width: min(440px, calc(100vw - 32px)); padding: 1.75rem 1.75rem 1.4rem; border: 0; border-radius: 14px;
  background: var(--surface); color: var(--text); text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 35, .28), 0 0 0 1px rgba(0, 0, 0, .04);
}
.confirm[open] { animation: confirm-entrada .16s ease-out; }
.confirm::backdrop { background: rgba(15, 23, 35, .5); backdrop-filter: blur(2px); }
.confirm__icono {
  width: 56px; height: 56px; margin: 0 auto .9rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-accent-soft); color: var(--brand-primary);
}
.confirm__icono svg { width: 28px; height: 28px; }
.confirm--peligro .confirm__icono { background: var(--error-bg); color: var(--danger); }
.confirm__titulo { margin: 0 0 .5rem; font-size: 1.2rem; }
.confirm__texto { margin: 0 0 1.4rem; color: var(--text-muted); line-height: 1.5; white-space: pre-line; }
.confirm__botones { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.confirm__botones .btn { min-width: 130px; }
.confirm__botones .btn:not(.btn--primary):not(.btn--danger) { background: var(--bg); border-color: var(--border); color: var(--text); }
@keyframes confirm-entrada { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .confirm[open] { animation: none; } }

/* ---- Consignatarios: acciones de cabecera y recuento por estado ---- */
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.page-head__actions .btn .icon { width: 1rem; height: 1rem; margin-right: .3rem; vertical-align: -.15em; }
.estado-tabs { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.estado-tab { display: flex; flex-direction: column; min-width: 110px; padding: .6rem .9rem; border-radius: var(--radius);
              background: var(--surface); border: 2px solid transparent; box-shadow: 0 2px 8px rgba(20,43,79,.06);
              color: inherit; text-decoration: none; transition: border-color .15s, background .15s; }
.estado-tab strong { font-size: 1.3rem; color: var(--brand-primary); line-height: 1.2; }
.estado-tab span { font-size: .8rem; color: var(--text-muted); }
.estado-tab:hover { border-color: var(--border); }
.estado-tab.is-active { border-color: var(--brand-accent); background: var(--brand-accent-soft); }
@media (max-width: 560px) { .estado-tab { min-width: calc(50% - .3rem); } }
