:root {
  --red: #CC0000;
  --red-dark: #9B0000;
  --ink: #1F252E;
  --muted: #68707C;
  --paper: #FFFFFF;
  --wash: #F4F6F9;
  --line: #E1E5EA;
  --soft-red: #FFF3F3;
  --green: #176B3A;
  --amber: #9B5D00;
  --blue: #1E5E8C;
  --shadow: 0 14px 34px rgba(31, 37, 46, 0.08);
  --shadow-soft: 0 4px 16px rgba(31, 37, 46, 0.06);
  --radius: 8px;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31,37,46,.035) 0 1px, transparent 1px 84px),
    linear-gradient(180deg, rgba(31,37,46,.03) 0 1px, transparent 1px 84px),
    radial-gradient(circle at top right, rgba(204,0,0,.06), transparent 34vw),
    var(--wash);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button { cursor: pointer; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.skip-link:focus { top: 16px; }

.app-shell {
  min-height: 100vh;
}

.loading-panel,
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loading-panel {
  gap: 16px;
  align-content: center;
  color: var(--muted);
  font-weight: 700;
}

.loading-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.auth__card {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(225,229,234,.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth__brand {
  min-height: 560px;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(135deg, rgba(178,0,0,.98), rgba(121,12,12,.98)),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 10px, transparent 10px 22px);
  color: #fff;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 900;
  letter-spacing: .02em;
}

.brand-mark img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 5px;
}

.auth__brand h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 5vw, 4.9rem);
  line-height: .95;
  letter-spacing: 0;
}

.auth__brand p {
  max-width: 32ch;
  margin: 18px 0 0;
  color: rgba(255,255,255,.86);
  line-height: 1.55;
}

.auth__form-wrap {
  padding: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h2,
h3,
p { margin-top: 0; }

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: .86rem;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #D9DEE5;
  border-radius: 6px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: rgba(204,0,0,.52);
  box-shadow: 0 0 0 3px rgba(204,0,0,.10);
  outline: 0;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.customer-picker {
  display: grid;
  gap: 6px;
}

.customer-picker__option {
  width: 100%;
  min-height: 44px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.customer-picker__option:hover {
  border-color: rgba(204,0,0,.42);
  background: var(--soft-red);
}

.customer-picker__option span,
.customer-picker__empty {
  color: var(--muted);
  font-size: .86rem;
}

.customer-picker__empty {
  padding: 10px 2px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 14px;
  font-weight: 900;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .58;
  transform: none;
}

.btn--primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 8px 20px rgba(204,0,0,.18);
}

.btn--primary:hover { background: var(--red-dark); }

.btn--ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn--ghost:hover {
  border-color: rgba(31,37,46,.26);
  background: #F9FAFB;
}

.btn--danger {
  background: #fff;
  color: var(--red-dark);
  border-color: rgba(204,0,0,.32);
}

.portal {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: rgba(255,255,255,.96);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 28px rgba(31,37,46,.04);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar__brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px;
  box-shadow: var(--shadow-soft);
}

.sidebar__brand strong {
  display: block;
  line-height: 1.1;
}

.sidebar__brand span {
  color: var(--muted);
  font-size: .82rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 7px;
  padding: 10px 12px;
  background: transparent;
  color: #4D5561;
  text-align: left;
  font-weight: 800;
}

.nav-button[aria-current="page"],
.nav-button:hover {
  background: var(--soft-red);
  color: var(--red-dark);
}

.nav-button[aria-current="page"] {
  box-shadow: inset 3px 0 0 var(--red);
}

.sidebar__footer {
  position: absolute;
  right: 22px;
  bottom: 22px;
  left: 22px;
}

.content {
  padding: 28px 32px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid--stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid--two {
  grid-template-columns: 1fr 1fr;
}

.customer-hero {
  min-height: 176px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
  padding: 26px;
  border: 1px solid rgba(204,0,0,.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(255,246,246,.92)),
    repeating-linear-gradient(135deg, rgba(204,0,0,.055) 0 1px, transparent 1px 18px);
  box-shadow: var(--shadow-soft);
}

.customer-hero h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.customer-hero p:not(.eyebrow) {
  max-width: 58ch;
  margin: 10px 0 0;
  color: var(--muted);
}

.customer-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-row h2 {
  margin-bottom: 6px;
}

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card__body { padding: 18px 20px; }

.stat {
  min-height: 116px;
  position: relative;
  overflow: hidden;
  border-top: 3px solid rgba(204,0,0,.74);
}

.stat::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -24px;
  width: 84px;
  height: 84px;
  border: 12px solid rgba(204,0,0,.07);
  transform: rotate(18deg);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar input,
.toolbar select {
  min-height: 42px;
  border: 1px solid #D9DEE5;
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
}

.toolbar input[type="search"] {
  width: min(520px, 52vw);
  flex: 0 1 520px;
}

.toolbar .btn {
  min-height: 40px;
  padding: 8px 12px;
  font-size: .9rem;
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: #69717D;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: #F8FAFC;
}

.table tbody td {
  line-height: 1.35;
}

.table tbody tr {
  transition: background .16s ease;
}

.table tbody tr:hover {
  background: #FBFCFE;
}

.table button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reports-grid {
  margin-top: 16px;
  align-items: start;
}

.report-list {
  display: grid;
  gap: 10px;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(31,37,46,.02);
}

.report-row span {
  display: grid;
  gap: 2px;
}

.report-row small {
  color: var(--muted);
  font-size: .78rem;
}

.report-row > strong,
.report-row > span:last-child {
  font-weight: 900;
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--wash);
  color: var(--ink);
  font-size: .72rem;
  font-weight: 900;
}

.badge--received { background: #EAF6EF; color: var(--green); }
.badge--preparing { background: #FFF5DE; color: var(--amber); }
.badge--transit { background: #E8F2F8; color: var(--blue); }
.badge--arrived { background: #EBF0FF; color: #244CA3; }
.badge--delivered { background: #E8F7E9; color: var(--green); }
.badge--hold { background: var(--soft-red); color: var(--red-dark); }
.badge--notice { background: #EAF6EF; color: var(--green); }
.badge--pending { background: #F1F3F5; color: #59616D; }

.locker-id {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px dashed rgba(204,0,0,.52);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--soft-red);
  color: var(--red-dark);
  font-weight: 900;
}

.package-list {
  display: grid;
  gap: 12px;
}

.package-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(204,0,0,.04), transparent 42%),
    #fff;
  box-shadow: 0 2px 10px rgba(31,37,46,.04);
}

.package-card__main {
  display: grid;
  grid-template-columns: minmax(140px, 180px) repeat(3, minmax(120px, 1fr));
  align-items: center;
  gap: 16px;
}

.package-card__title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.package-code {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px dashed rgba(204,0,0,.38);
  border-radius: 999px;
  background: var(--soft-red);
  color: var(--red-dark);
  font-size: .78rem;
  font-weight: 900;
}

.package-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  min-width: 0;
}

.package-card__status {
  display: flex;
  justify-content: flex-end;
  min-width: 210px;
}

.meta {
  display: contents;
  color: var(--muted);
  font-size: .88rem;
}

.package-note {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 4px;
}

.meta span {
  display: grid;
  gap: 3px;
  min-height: 36px;
  padding-left: 12px;
  border-left: 1px solid #E7EBF0;
  background: transparent;
  overflow-wrap: anywhere;
}

.meta strong {
  color: #707986;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.empty {
  padding: 42px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.82);
  text-align: center;
  color: var(--muted);
}

.empty--customer {
  display: grid;
  gap: 6px;
}

.empty--customer strong {
  color: var(--ink);
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(0,0,0,.38);
}

.drawer.is-open {
  display: grid;
  justify-items: end;
}

.drawer__panel {
  width: min(560px, 100%);
  height: 100vh;
  overflow: auto;
  background: #fff;
  box-shadow: -20px 0 50px rgba(31,37,46,.18);
}

.drawer__panel--wide {
  width: min(820px, 100%);
}

.drawer__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.drawer__head h2 { margin: 0; }

.drawer__body {
  padding: 20px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.notice-preview h3 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.notice-preview .table {
  min-width: 0;
  table-layout: fixed;
}

.notice-preview .table th,
.notice-preview .table td {
  overflow-wrap: anywhere;
}

.notice-comment {
  margin-top: 18px;
}

.table--compact {
  min-width: 0;
}

.table--compact th,
.table--compact td {
  padding: 10px 11px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 7px;
  padding: 14px 16px;
  background: #1F252E;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.error-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(204,0,0,.28);
  border-radius: 7px;
  background: var(--soft-red);
  color: var(--red-dark);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .auth__card,
  .portal,
  .grid--stats,
  .grid--two {
    grid-template-columns: 1fr;
  }

  .auth__brand {
    min-height: 320px;
  }

  .portal {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar__footer {
    position: static;
    margin-top: 20px;
  }
}

@media (max-width: 640px) {
  .auth,
  .content {
    padding: 14px;
  }

  .auth__form-wrap,
  .auth__brand {
    padding: 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-row,
  .package-card {
    grid-template-columns: 1fr;
  }

  .package-card__status {
    justify-content: flex-start;
    min-width: 0;
  }

  .package-card__title {
    align-items: flex-start;
  }

  .package-card__main {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .meta {
    display: grid;
    gap: 7px;
  }

  .meta span {
    min-height: 0;
    padding: 7px 9px;
    border: 1px solid #E7EBF0;
    border-radius: 7px;
    background: #FAFBFC;
  }

  .package-note {
    grid-column: auto;
  }

  .customer-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 20px;
  }

  .customer-stats,
  .meta {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .table-wrap {
    overflow: visible;
  }

  .table {
    min-width: 0;
  }

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 8px 20px rgba(20,20,20,.05);
    overflow: hidden;
  }

  .table td {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 12px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
  }

  .table td:last-child {
    border-bottom: 0;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .table td[data-label="Seleccion"] {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .table td[data-label="Seleccion"]::before {
    content: "Seleccionar";
  }

  .table-actions {
    justify-content: flex-start;
  }
}
