/* === Reset y sistema visual === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5ece8;
  --bg-soft: #fff8f4;
  --surface: rgba(255, 251, 249, 0.88);
  --surface-strong: rgba(255, 253, 252, 0.96);
  --surface-dark: #140f11;
  --primary: #7c1730;
  --primary-dark: #551021;
  --primary-light: #b2435f;
  --primary-soft: #f4e2e8;
  --success: #18794e;
  --warning: #b7791f;
  --danger: #b83245;
  --gray-50: #fffaf8;
  --gray-100: #f6efeb;
  --gray-200: #eadfd9;
  --gray-300: #d7c7c0;
  --gray-500: #7a666c;
  --gray-700: #4f4145;
  --gray-900: #171214;
  --border: rgba(81, 20, 35, 0.12);
  --border-strong: rgba(81, 20, 35, 0.24);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 30px;
  --shadow: 0 18px 40px rgba(25, 12, 17, 0.08), 0 2px 12px rgba(25, 12, 17, 0.06);
  --shadow-lg: 0 28px 80px rgba(30, 12, 17, 0.16), 0 8px 24px rgba(30, 12, 17, 0.1);
  --transition: 0.22s ease;
  --font-sans: "IBM Plex Sans", "Aptos", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

html { font-size: 16px; color-scheme: light; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 8% 8%, rgba(124, 23, 48, 0.18), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(20, 15, 17, 0.16), transparent 20%),
    linear-gradient(180deg, #f9f2ef 0%, #efe4df 100%);
  color: var(--gray-900);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: -1;
  filter: blur(24px);
}

body::before {
  top: 4rem;
  right: -5rem;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  background: rgba(124, 23, 48, 0.08);
}

body::after {
  left: -4rem;
  bottom: 3rem;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  background: rgba(20, 15, 17, 0.06);
}

body.login-mode {
  background:
    radial-gradient(circle at 18% 18%, rgba(178, 67, 95, 0.22), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.08), transparent 20%),
    linear-gradient(135deg, #140f11 0%, #2b1119 42%, #571729 100%);
}

body.nav-locked { overflow: hidden; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--primary-dark); }

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

::selection {
  background: rgba(124, 23, 48, 0.18);
  color: var(--gray-900);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(81, 20, 35, 0.06); border-radius: 999px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 23, 48, 0.42), rgba(81, 20, 35, 0.72));
  border-radius: 999px;
}

/* === Layout principal === */
.app {
  display: flex;
  gap: 1.5rem;
  min-height: 100vh;
  padding: 1.25rem;
  align-items: flex-start;
  transition: gap var(--transition);
}

.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1900;
  width: 3.05rem;
  height: 3.05rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 23, 48, 0.98), rgba(60, 11, 23, 0.98));
  box-shadow: 0 20px 38px rgba(66, 11, 24, 0.24);
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 1700;
  background: rgba(20, 15, 17, 0.44);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.sidebar {
  width: 290px;
  flex-shrink: 0;
  position: sticky;
  top: 1.25rem;
  height: calc(100vh - 2.5rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  border-radius: 30px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(178, 67, 95, 0.18), transparent 26%),
    linear-gradient(180deg, #1a1416 0%, #0c0a0b 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
  transition: width var(--transition), padding var(--transition), transform var(--transition), border-radius var(--transition);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), transparent);
  pointer-events: none;
}

.sidebar-header {
  position: relative;
  display: grid;
  gap: 0.75rem;
  padding: 0.35rem 3.1rem 1.25rem 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-collapse-toggle {
  position: absolute;
  top: 0.25rem;
  right: 0;
  width: 2.55rem;
  height: 2.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.sidebar-collapse-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-collapse-toggle svg { transition: transform var(--transition); }

.brand-mark {
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #d56581 0%, #7c1730 58%, #51101f 100%);
  color: #fff;
  font-size: 1.55rem;
  font-weight: 700;
  font-family: var(--font-sans);
  box-shadow: 0 16px 30px rgba(89, 16, 36, 0.32);
}

.brand-copy { display: grid; gap: 0.2rem; }

.brand-overline {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.58);
}

.sidebar-header h1 {
  font-size: 2rem;
  line-height: 0.95;
}

.sidebar-header small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.92rem;
}

.brand-note {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f5dce2;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.sidebar nav {
  flex: 1;
  overflow: auto;
  padding-right: 0.25rem;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.3rem;
  padding: 0.78rem 0.9rem;
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.96rem;
  font-weight: 600;
  transition: transform var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
}

.sidebar nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 0;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe6ed, #f3a5b7);
  transition: height var(--transition);
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: #fff;
  text-decoration: none;
}

.sidebar nav a:hover {
  transform: translateX(4px);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(124, 23, 48, 0.92), rgba(67, 11, 25, 0.98));
  box-shadow: 0 18px 36px rgba(73, 11, 27, 0.34);
}

.sidebar nav a.active::before { height: 62%; }

.sidebar nav a .icon {
  width: 2.55rem;
  height: 2.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar nav a.active .icon {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-text { flex: 1; line-height: 1.15; }

.sidebar-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 0.85rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.user-avatar {
  width: 2.9rem;
  height: 2.9rem;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(124, 23, 48, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
}

.user-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.5);
}

.sidebar-footer .user-name {
  font-weight: 700;
  font-size: 1rem;
}

.sidebar-footer .user-role {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.82rem;
}

.user-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.user-date {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: capitalize;
}

.user-role-badge.badge-info {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-footer button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

body.sidebar-collapsed .app { gap: 1rem; }

body.sidebar-collapsed .sidebar {
  width: 96px;
  padding: 1rem 0.7rem;
}

body.sidebar-collapsed .sidebar-header {
  justify-items: center;
  gap: 0.75rem;
  padding: 0 0 1rem;
  margin-bottom: 1rem;
}

body.sidebar-collapsed .sidebar-collapse-toggle {
  position: static;
  order: 2;
}

body.sidebar-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }

body.sidebar-collapsed .brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 16px;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .brand-note,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .user-card > div,
body.sidebar-collapsed .user-meta-row,
body.sidebar-collapsed .sidebar-footer button {
  display: none;
}

body.sidebar-collapsed .sidebar nav {
  width: 100%;
  padding-right: 0;
}

body.sidebar-collapsed .sidebar nav a {
  justify-content: center;
  gap: 0;
  padding: 0.62rem;
  margin-bottom: 0.45rem;
}

body.sidebar-collapsed .sidebar nav a:hover {
  transform: translateY(-1px);
}

body.sidebar-collapsed .sidebar nav a::before {
  left: 50%;
  top: auto;
  bottom: -0.2rem;
  width: 40%;
  height: 0;
  transform: translateX(-50%);
}

body.sidebar-collapsed .sidebar nav a.active::before { height: 3px; }

body.sidebar-collapsed .sidebar nav a .icon {
  width: 2.75rem;
  height: 2.75rem;
}

body.sidebar-collapsed .sidebar-footer {
  justify-items: center;
  padding-top: 0.85rem;
}

body.sidebar-collapsed .user-card {
  justify-content: center;
  gap: 0;
}

.sidebar-nav-tooltip {
  position: fixed;
  z-index: 2600;
  max-width: 220px;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(20, 15, 17, 0.98), rgba(85, 16, 33, 0.98));
  color: #fff;
  box-shadow: 0 18px 34px rgba(20, 15, 17, 0.24);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-4px);
  transition: opacity var(--transition), transform var(--transition);
}

.sidebar-nav-tooltip::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: rgba(20, 15, 17, 0.98);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateY(-50%) rotate(45deg);
}

.sidebar-nav-tooltip.is-visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.main-content {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 2.5rem);
  position: relative;
  overflow-y: auto;
  padding: 2rem clamp(1.3rem, 2.7vw, 2.25rem);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 253, 252, 0.85), rgba(248, 241, 237, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}

.main-content::before,
.main-content::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.main-content::before {
  top: -4rem;
  right: -4rem;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 23, 48, 0.08), transparent 72%);
}

.main-content::after {
  left: -6rem;
  bottom: -7rem;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 15, 17, 0.05), transparent 72%);
}

#app-content > * {
  position: relative;
  z-index: 1;
  animation: pageIn 0.4s ease both;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Login === */
.login-page {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: auto;
}

.login-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
}

.login-showcase,
.login-card {
  border-radius: 32px;
  box-shadow: var(--shadow-lg);
}

.login-showcase {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 1rem;
  min-height: 38rem;
  padding: clamp(2rem, 4vw, 3rem);
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.12), transparent 20%),
    linear-gradient(145deg, #150f11 0%, #39111f 46%, #78182f 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-showcase::after {
  content: "";
  position: absolute;
  right: -4rem;
  bottom: -5rem;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 68%);
  pointer-events: none;
}

.login-logo {
  width: 4.25rem;
  height: 4.25rem;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 1.9rem;
  font-weight: 700;
  font-family: var(--font-sans);
}

.login-eyebrow,
.panel-eyebrow,
.login-card-kicker {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.7rem;
  font-weight: 700;
}

.login-eyebrow { color: rgba(255, 255, 255, 0.64); }

.login-showcase h1 {
  max-width: 9ch;
  font-size: 4rem;
  line-height: 0.92;
}

.login-showcase p {
  max-width: 34rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
  line-height: 1.65;
}

.login-highlights {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.login-highlight {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.login-highlight strong {
  font-family: var(--font-sans);
  font-size: 1.08rem;
}

.login-highlight span {
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.45;
  font-size: 0.9rem;
}

.login-card {
  align-self: center;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background: linear-gradient(180deg, rgba(255, 254, 253, 0.98), rgba(247, 240, 236, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
}

.login-card-head {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1.75rem;
}

.login-card-kicker,
.panel-eyebrow { color: var(--primary); }

.login-card h2 {
  font-size: 2.15rem;
  line-height: 1;
}

.login-card p {
  color: var(--gray-500);
  line-height: 1.55;
}

/* === Componentes compartidos === */
.page-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  overflow: hidden;
  margin-bottom: 1.5rem;
  padding: 1.45rem 1.7rem;
  border-radius: 28px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.12), transparent 18%),
    linear-gradient(135deg, rgba(92, 13, 29, 0.98), rgba(21, 15, 17, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 22px 48px rgba(72, 10, 27, 0.24);
}

.page-header::after {
  content: "";
  position: absolute;
  right: -2.5rem;
  top: -2rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.page-header > * {
  position: relative;
  z-index: 1;
}

.page-header h2 {
  font-size: 2.6rem;
  line-height: 0.95;
}

.page-header p {
  max-width: 58ch;
  margin-top: 0.55rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.45;
}

.page-header > div {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-header > .page-title {
  display: grid;
  align-items: start;
  gap: 0;
}

.card {
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
  padding: 1.25rem;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(124, 23, 48, 0.24), transparent 56%);
  pointer-events: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1.35rem;
  line-height: 1;
}

.card-header p {
  margin-top: 0.35rem;
  color: var(--gray-500);
  font-size: 0.9rem;
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  padding: 1.35rem;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 241, 237, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  text-align: left;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--primary);
  pointer-events: none;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -1.75rem;
  bottom: -2rem;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 23, 48, 0.08), transparent 72%);
  pointer-events: none;
}

.stat-card .stat-value {
  position: relative;
  z-index: 1;
  font-size: 3rem;
  line-height: 1;
  font-weight: 700;
  font-family: var(--font-sans);
}

.stat-card .stat-label {
  position: relative;
  z-index: 1;
  max-width: 16ch;
  margin-top: 0.7rem;
  color: var(--gray-500);
  font-size: 0.95rem;
  line-height: 1.4;
}

.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.info::before { background: var(--primary); }
.stat-card.info .stat-value { color: var(--primary); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.compact-stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 1rem;
}

.compact-stats .stat-card {
  min-height: 112px;
  padding: 1rem;
}

.compact-stats .stat-card .stat-value {
  font-size: 2rem;
}

/* === Tablas === */
.table-wrapper {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.74);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.94rem;
}

th, td {
  padding: 0.95rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(81, 20, 35, 0.08);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(124, 23, 48, 0.04);
  color: var(--gray-500);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(124, 23, 48, 0.05); }
tbody tr:last-child td { border-bottom: none; }

.table-number {
  font-variant-numeric: tabular-nums;
}

.table-subvalue {
  margin-top: 0.22rem;
  color: var(--gray-500);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-value {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.5rem;
  color: var(--gray-900);
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 0.72rem;
  height: 0.72rem;
  flex: 0 0 0.72rem;
  border-radius: 999px;
  background: var(--gray-300);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.74),
    0 0 0 3px rgba(122, 102, 108, 0.12);
}

.status-value-success { color: var(--success); }
.status-value-warning { color: var(--warning); }
.status-value-danger { color: var(--danger); }
.status-value-info { color: var(--primary); }
.status-value-gray,
.status-value-muted { color: var(--gray-700); }

.status-dot-success {
  background: var(--success);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.74),
    0 0 0 3px rgba(24, 121, 78, 0.14);
}

.status-dot-warning {
  background: var(--warning);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.74),
    0 0 0 3px rgba(183, 121, 31, 0.16);
}

.status-dot-danger {
  background: var(--danger);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.74),
    0 0 0 3px rgba(184, 50, 69, 0.15);
}

.status-dot-info {
  background: var(--primary);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.74),
    0 0 0 3px rgba(124, 23, 48, 0.14);
}

.status-dot-gray,
.status-dot-muted {
  background: var(--gray-300);
}

/* === Formularios === */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--gray-700);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--gray-900);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(124, 23, 48, 0.48);
  box-shadow: 0 0 0 4px rgba(124, 23, 48, 0.12), 0 12px 22px rgba(124, 23, 48, 0.08);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* === Botones === */
.btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1.1rem;
  border: none;
  border-radius: 16px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.58; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 14px 28px rgba(92, 13, 29, 0.24);
}

.btn-primary:hover:not(:disabled) { box-shadow: 0 18px 34px rgba(92, 13, 29, 0.3); }

.btn-success {
  background: linear-gradient(135deg, #209663, #156846);
  color: #fff;
  box-shadow: 0 14px 28px rgba(24, 121, 78, 0.22);
}

.btn-warning {
  background: linear-gradient(135deg, #d49b40, #b7791f);
  color: #fff;
  box-shadow: 0 14px 28px rgba(183, 121, 31, 0.2);
}

.btn-danger {
  background: linear-gradient(135deg, #cf4b62, #9f2035);
  color: #fff;
  box-shadow: 0 14px 28px rgba(159, 32, 53, 0.22);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  color: var(--gray-900);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--border-strong);
}

.page-header .btn-outline {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.page-header .btn-primary {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: none;
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  border-radius: 14px;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  border: 1px solid transparent;
}

.badge-info {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(124, 23, 48, 0.12);
}

.badge-success {
  background: rgba(24, 121, 78, 0.12);
  color: var(--success);
  border-color: rgba(24, 121, 78, 0.18);
}

.badge-warning {
  background: rgba(183, 121, 31, 0.14);
  color: var(--warning);
  border-color: rgba(183, 121, 31, 0.18);
}

.badge-danger {
  background: rgba(184, 50, 69, 0.12);
  color: var(--danger);
  border-color: rgba(184, 50, 69, 0.18);
}

.badge-gray {
  background: rgba(122, 102, 108, 0.12);
  color: var(--gray-700);
  border-color: rgba(122, 102, 108, 0.16);
}

/* === Busquedas y filtros === */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.85rem;
  border-radius: 22px;
  background: rgba(255, 251, 249, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.search-bar input,
.search-bar select,
.search-bar textarea {
  flex: 1 1 220px;
  min-width: 0;
}

.search-bar input { max-width: none; }

.helper-text {
  color: var(--gray-500);
  font-size: 0.9rem;
  line-height: 1.5;
}

.helper-text.success { color: var(--success); }
.helper-text.error { color: var(--danger); }

/* === Escaner e importaciones === */
.scanner-layout,
.import-layout {
  align-items: start;
}

.scanner-card {
  min-height: 100%;
}

.scanner-video-frame {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  margin-bottom: 0.9rem;
  border-radius: 24px;
  background:
    radial-gradient(circle at center, rgba(124, 23, 48, 0.16), transparent 42%),
    linear-gradient(135deg, #1a1416, #070606);
  border: 1px solid rgba(81, 20, 35, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.scanner-video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reticle {
  position: absolute;
  width: min(58%, 260px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 24px;
  box-shadow:
    0 0 0 999px rgba(7, 6, 6, 0.2),
    0 0 24px rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.scanner-reticle::before,
.scanner-reticle::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  height: 2px;
  background: rgba(244, 226, 232, 0.86);
}

.scanner-reticle::before { top: 50%; }
.scanner-reticle::after {
  top: 50%;
  transform: rotate(90deg);
}

.scanner-actions,
.scanner-manual-form,
.import-form {
  display: grid;
  gap: 0.75rem;
}

.scanner-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.scanner-result {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.2rem;
  padding: 1rem;
  border-radius: 20px;
  background: rgba(124, 23, 48, 0.06);
  border: 1px solid rgba(124, 23, 48, 0.14);
}

.scanner-result.empty {
  background: rgba(255, 255, 255, 0.58);
  border-color: var(--border);
}

.scanner-result.error {
  background: rgba(184, 50, 69, 0.08);
  border-color: rgba(184, 50, 69, 0.18);
}

.scan-result-head {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.scanner-result code,
.import-columns code,
.qr-meta code {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.55rem;
  border-radius: 10px;
  background: rgba(20, 15, 17, 0.08);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.import-columns {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
  padding: 0.9rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--border);
}

.import-columns span {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.import-result-card {
  margin-top: 1rem;
}

/* === Naves y mapa === */
.nave-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.nave-tab {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-weight: 700;
  color: var(--gray-700);
  transition: background var(--transition), border-color var(--transition), transform var(--transition), color var(--transition);
}

.nave-tab:hover {
  background: rgba(255, 255, 255, 0.94);
  transform: translateY(-1px);
}

.nave-tab.active {
  background: linear-gradient(135deg, var(--primary-soft), rgba(255, 255, 255, 0.94));
  border-color: rgba(124, 23, 48, 0.28);
  color: var(--primary-dark);
}

.rack-grid { display: grid; gap: 0.45rem; }

.rack-cell {
  position: relative;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  overflow: hidden;
  padding: 0.55rem 0.45rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fffdfc, #faf2ee);
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
}

.rack-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.rack-cell .rack-name {
  font-size: 0.84rem;
  font-weight: 800;
}

.rack-cell .rack-info {
  font-size: 0.62rem;
  color: var(--gray-500);
}

.rack-cell .rack-product {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gray-700);
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.12;
}

.rack-cell .rack-stock {
  font-size: 0.74rem;
  font-weight: 800;
}

.rack-cell .rack-venc { font-size: 0.58rem; }

.rack-cell.s-libre {
  background: linear-gradient(180deg, #efebe8, #e6e0dc);
  border-color: rgba(122, 102, 108, 0.14);
}

.rack-cell.s-verde {
  background: linear-gradient(180deg, rgba(24, 121, 78, 0.16), rgba(255, 255, 255, 0.9));
  border-color: rgba(24, 121, 78, 0.3);
}

.rack-cell.s-verde .rack-stock { color: var(--success); }

.rack-cell.s-amarillo {
  background: linear-gradient(180deg, rgba(183, 121, 31, 0.16), rgba(255, 255, 255, 0.9));
  border-color: rgba(183, 121, 31, 0.28);
}

.rack-cell.s-amarillo .rack-venc {
  color: var(--warning);
  font-weight: 700;
}

.rack-cell.s-rojo {
  background: linear-gradient(180deg, rgba(184, 50, 69, 0.16), rgba(255, 255, 255, 0.9));
  border-color: rgba(184, 50, 69, 0.28);
}

.rack-cell.s-rojo .rack-stock { color: var(--danger); }

.rack-cell.s-busqueda {
  border-color: rgba(124, 23, 48, 0.5) !important;
  box-shadow: 0 0 0 4px rgba(124, 23, 48, 0.12);
}

.rack-cell.t-pasillo {
  min-height: 56px;
  background: linear-gradient(180deg, #3a3337, #1f1a1c);
  border-color: #3a3337;
  color: #d5cad0;
  cursor: default;
}

.rack-cell.t-bloqueado {
  min-height: 56px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04) 6px, rgba(0, 0, 0, 0.08) 6px, rgba(0, 0, 0, 0.08) 12px),
    linear-gradient(180deg, #3a2a2f, #1e1719);
  border-color: #3a2a2f;
  color: #c7b4bc;
  cursor: default;
}

.rack-cell.t-picking {
  background: linear-gradient(180deg, rgba(124, 23, 48, 0.18), rgba(255, 251, 249, 0.92));
  border-color: rgba(124, 23, 48, 0.32);
}

.rack-cell.t-picking .rack-stock,
.rack-cell.t-picking .rack-info,
.rack-cell.t-picking .rack-venc {
  color: var(--primary-dark);
}

.rack-cell.t-vacia {
  min-height: 56px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px dashed var(--border-strong);
  cursor: default;
}

.mapa-editor-layout { display: flex; gap: 1rem; }

.mapa-editor-panel {
  width: 240px;
  flex-shrink: 0;
  max-height: 75vh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.mapa-editor-panel h4 {
  margin-bottom: 0.8rem;
  font-size: 1rem;
}

.mapa-editor-grid { flex: 1; }

.drag-rack {
  margin-bottom: 0.45rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  cursor: grab;
  font-size: 0.88rem;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.drag-rack:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.drag-rack:active { cursor: grabbing; }

.rack-cell.drag-over {
  border-color: rgba(124, 23, 48, 0.48) !important;
  background: rgba(244, 226, 232, 0.92) !important;
}

.rack-cell.dragging { opacity: 0.45; }

/* === Modales === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(19, 13, 15, 0.5);
  backdrop-filter: blur(8px);
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 1.6rem;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 240, 236, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-lg);
  animation: pageIn 0.24s ease both;
}

.modal h3 {
  margin-bottom: 1.2rem;
  font-size: 1.8rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.35rem;
}

.qr-modal {
  max-width: 430px;
}

.qr-content {
  display: grid;
  justify-items: center;
  gap: 1rem;
  min-height: 240px;
}

.qr-preview {
  width: min(280px, 100%);
  padding: 1rem;
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.qr-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.qr-meta {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  color: var(--gray-500);
  text-align: center;
}

.danger-confirm-modal {
  max-width: 520px;
}

.danger-confirm-icon {
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  border-radius: 22px;
  color: var(--danger);
  background:
    radial-gradient(circle at top right, rgba(184, 50, 69, 0.18), transparent 58%),
    rgba(184, 50, 69, 0.1);
  border: 1px solid rgba(184, 50, 69, 0.18);
}

.danger-confirm-modal p {
  color: var(--gray-500);
  line-height: 1.55;
}

.danger-confirm-modal strong {
  color: var(--gray-900);
}

.confirm-user-card {
  display: grid;
  gap: 0.2rem;
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
}

.confirm-user-card span {
  color: var(--gray-900);
  font-weight: 800;
}

.confirm-user-card small {
  color: var(--gray-500);
  font-weight: 600;
}

/* === Toasts === */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  min-width: 250px;
  max-width: 360px;
  padding: 1rem 1.15rem;
  border-radius: 18px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.28s ease both;
}

.toast-success { background: linear-gradient(135deg, #209663, #156846); }
.toast-error { background: linear-gradient(135deg, #cf4b62, #9f2035); }
.toast-warning { background: linear-gradient(135deg, #d49b40, #b7791f); }

/* === Aviso de cambios en vivo === */
.realtime-banner {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 2600;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  width: min(620px, calc(100vw - 2.5rem));
  padding: 1rem;
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(135deg, rgba(92, 13, 29, 0.98), rgba(20, 15, 17, 0.96));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 60px rgba(30, 12, 17, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity var(--transition), transform var(--transition);
}

.realtime-banner.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.realtime-banner strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

.realtime-banner p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  line-height: 1.4;
}

.realtime-banner-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.realtime-banner .btn-primary {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: none;
}

.realtime-banner .btn-outline {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* === Loading y estados vacios === */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(81, 20, 35, 0.14);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--gray-500);
  font-weight: 600;
}

.empty-state {
  padding: 2.8rem 1rem;
  text-align: center;
  color: var(--gray-500);
}

.empty-state .icon {
  margin-bottom: 0.5rem;
  font-size: 2.6rem;
}

/* === Notificaciones === */
.notif-bell-fixed {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1500;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, rgba(124, 23, 48, 0.98), rgba(60, 11, 23, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 38px rgba(66, 11, 24, 0.28);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.notif-bell-fixed:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 44px rgba(66, 11, 24, 0.34);
}

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 0.66rem;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(17, 11, 13, 0.16);
}

.notif-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1rem;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 253, 252, 0.98), rgba(244, 235, 231, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.notif-panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0 1rem;
  background: linear-gradient(180deg, rgba(255, 253, 252, 1) 72%, rgba(255, 253, 252, 0));
}

.notif-panel h3 {
  font-size: 1.6rem;
  line-height: 1;
}

.notif-item {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 0.65rem;
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid rgba(81, 20, 35, 0.08);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
}

.notif-item.unread {
  background: rgba(124, 23, 48, 0.07);
  border-color: rgba(124, 23, 48, 0.14);
}

.notif-item .notif-msg {
  flex: 1;
  line-height: 1.45;
}

.notif-item .notif-time {
  font-size: 0.72rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.notif-item .notif-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.notif-empty {
  padding: 1.5rem 0.2rem;
  color: var(--gray-500);
}

/* === Busqueda global === */
.search-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 3000;
  overflow-y: auto;
  max-height: 300px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  background: rgba(255, 253, 252, 0.98);
  box-shadow: var(--shadow-lg);
  color: var(--gray-900);
}

.search-dropdown .search-group { padding: 0.3rem 0; }

.search-dropdown .search-group-title {
  padding: 0.4rem 0.9rem;
  color: var(--gray-500);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.search-dropdown .search-result {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.search-dropdown .search-result:hover { background: rgba(124, 23, 48, 0.05); }

/* === Semáforo de dashboard === */
.semaforo-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(260px, 1fr);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 8px;
  background: rgba(255, 253, 252, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.semaforo-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 241, 237, 0.72));
}

.semaforo-dot {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  display: block;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.72), 0 12px 24px rgba(20, 15, 17, 0.12);
}

.semaforo-summary h3 {
  margin-top: 0.25rem;
  font-size: 2rem;
  line-height: 1;
}

.semaforo-summary p {
  margin-top: 0.35rem;
  color: var(--gray-500);
  font-weight: 600;
}

.semaforo-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.semaforo-counts div {
  display: grid;
  align-content: center;
  gap: 0.35rem;
  min-height: 7rem;
  padding: 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.semaforo-counts strong {
  font-family: var(--font-sans);
  font-size: 2rem;
  line-height: 1;
}

.semaforo-counts span {
  color: var(--gray-500);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.semaforo-detail {
  grid-column: 1 / -1;
}

.semaforo-verde .semaforo-dot { background: var(--success); }
.semaforo-amarillo .semaforo-dot { background: var(--warning); }
.semaforo-rojo .semaforo-dot { background: var(--danger); }
.semaforo-verde .semaforo-counts strong { color: var(--success); }
.semaforo-amarillo .semaforo-counts strong { color: var(--warning); }
.semaforo-rojo .semaforo-counts strong { color: var(--danger); }

/* === FEFO y metricas === */
.route-summary-card {
  margin-bottom: 1rem;
}

.route-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.route-group-summary {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--border);
}

.route-group-summary span {
  color: var(--gray-500);
  font-size: 0.84rem;
  font-weight: 600;
}

.route-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.route-chip {
  display: inline-grid;
  gap: 0.18rem;
  min-width: 150px;
  padding: 0.65rem 0.78rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 241, 237, 0.9));
  border: 1px solid var(--border);
}

.route-chip small {
  color: var(--gray-500);
  font-size: 0.76rem;
  font-weight: 600;
}

.route-chip.muted {
  place-items: center;
  color: var(--gray-500);
  font-weight: 700;
}

.fefo-step {
  margin-bottom: 0.75rem;
  padding: 1rem;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.fefo-step.active {
  border-color: rgba(124, 23, 48, 0.28);
  background: rgba(244, 226, 232, 0.72);
}

.fefo-step.done {
  border-color: rgba(24, 121, 78, 0.2);
  background: rgba(24, 121, 78, 0.08);
  opacity: 0.84;
}

.fefo-step h4 { margin-bottom: 0.5rem; }

.route-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
}

.route-step-number {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-weight: 800;
  box-shadow: 0 12px 22px rgba(92, 13, 29, 0.18);
}

.route-step-body {
  min-width: 0;
}

.route-step-body p {
  color: var(--gray-500);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rack-cell.pulse-highlight {
  animation: pulse 1.5s ease-in-out infinite;
  border-color: rgba(124, 23, 48, 0.52) !important;
  box-shadow: 0 0 0 3px rgba(124, 23, 48, 0.18);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(124, 23, 48, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(124, 23, 48, 0.06); }
}

.metric-bar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.9rem;
}

.metric-bar .bar-label {
  width: auto;
  text-align: left;
  color: var(--gray-500);
  font-weight: 600;
}

.metric-bar .bar-fill {
  min-width: 6px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  box-shadow: 0 10px 18px rgba(124, 23, 48, 0.16);
}

.metric-bar .bar-value {
  font-size: 0.82rem;
  font-weight: 700;
}

/* === Auditoría === */
.audit-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.audit-filter {
  width: min(100%, 280px);
}

.audit-action-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: rgba(124, 23, 48, 0.09);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.audit-detail {
  display: inline-block;
  max-width: 26rem;
  overflow: hidden;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(81, 20, 35, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--gray-700);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.audit-timeline {
  display: grid;
  gap: 0.75rem;
}

.audit-timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.7rem;
  border-radius: 18px;
  background: rgba(124, 23, 48, 0.045);
}

.audit-timeline-item strong {
  color: var(--gray-900);
  font-size: 0.92rem;
}

.audit-timeline-item p {
  margin-top: 0.18rem;
  color: var(--gray-500);
  font-size: 0.82rem;
}

.audit-errors-card {
  border-color: rgba(184, 50, 69, 0.12);
}

.audit-error-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.audit-error-stats .stat-card {
  min-height: 104px;
  padding: 0.95rem;
}

.audit-error-stats .stat-card .stat-value {
  font-size: 2rem;
}

.audit-errors-insights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.audit-errors-insights > div {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(81, 20, 35, 0.08);
}

.audit-errors-insights h4 {
  margin-bottom: 0.8rem;
  color: var(--gray-900);
  font-size: 1rem;
}

.audit-error-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.2rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.audit-error-status-danger {
  background: rgba(184, 50, 69, 0.12);
  color: var(--danger);
}

.audit-error-status-warning {
  background: rgba(183, 121, 31, 0.14);
  color: var(--warning);
}

.audit-error-status-info {
  background: rgba(124, 23, 48, 0.09);
  color: var(--primary-dark);
}

.audit-path {
  display: inline-block;
  max-width: 20rem;
  overflow: hidden;
  color: var(--gray-700);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
}

.pagination-controls span {
  color: var(--gray-500);
  font-size: 0.88rem;
  font-weight: 700;
}

.empty-state.compact {
  padding: 0.75rem 0;
  color: var(--gray-500);
  font-size: 0.92rem;
  text-align: left;
}

/* === Responsive === */
@media (max-width: 1200px) {
  .app { gap: 1rem; padding: 1rem; }
  .sidebar { width: 260px; }
  .main-content { padding: 1.6rem; }
}

@media (max-width: 1024px) {
  .app {
    display: block;
    padding: 1rem;
  }

  .sidebar-mobile-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    width: min(330px, calc(100vw - 1.5rem));
    height: auto;
    max-height: none;
    z-index: 1800;
    transform: translateX(calc(-100% - 1.5rem));
    border-radius: 24px;
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-collapsed .sidebar {
    width: min(330px, calc(100vw - 1.5rem));
    padding: 1.25rem;
  }

  body.sidebar-collapsed .sidebar-header {
    justify-items: stretch;
    padding: 0.35rem 3.1rem 1.25rem 0;
    margin-bottom: 1.25rem;
  }

  body.sidebar-collapsed .sidebar-collapse-toggle {
    position: absolute;
    top: 0.25rem;
    right: 0;
    order: initial;
  }

  body.sidebar-collapsed .sidebar-collapse-toggle svg { transform: none; }

  body.sidebar-collapsed .brand-copy { display: grid; }
  body.sidebar-collapsed .brand-note { display: inline-flex; }
  body.sidebar-collapsed .nav-text { display: inline; }
  body.sidebar-collapsed .user-card > div { display: block; }
  body.sidebar-collapsed .user-meta-row { display: flex; }
  body.sidebar-collapsed .sidebar-footer button { display: inline-flex; }

  .sidebar nav {
    display: block;
    overflow: auto;
    padding-right: 0.25rem;
  }

  .sidebar nav a {
    flex: none;
    margin-bottom: 0.3rem;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .main-content {
    min-height: calc(100vh - 2rem);
    margin-top: 3.7rem;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .audit-dashboard { grid-template-columns: 1fr; }
  .audit-errors-insights { grid-template-columns: 1fr; }
  .semaforo-panel { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-showcase { min-height: 0; }
  .mapa-editor-layout { flex-direction: column; }
  .mapa-editor-panel { width: 100%; max-height: none; }
}

@media (max-width: 768px) {
  html { font-size: 15px; }

  .app { padding: 0.75rem; }
  .main-content {
    padding: 1rem;
    border-radius: 24px;
  }

  .page-header {
    padding: 1.2rem;
    border-radius: 24px;
  }

  .page-header h2 { font-size: 2rem; }
  .login-showcase h1 { font-size: 3rem; }
  .stat-card .stat-value { font-size: 2.4rem; }

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

  .notif-panel {
    top: 0.75rem;
    right: 0.75rem;
    width: auto;
    height: calc(100vh - 1.5rem);
  }

  .notif-bell-fixed {
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .table-wrapper { border-radius: 18px; }
  th, td { padding: 0.8rem 0.75rem; }
  .audit-filter { width: 100%; }
  .audit-detail { max-width: 16rem; }
  .audit-error-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-path { max-width: 14rem; }

  .modal {
    padding: 1.25rem;
    border-radius: 22px;
  }

  .scanner-actions {
    grid-template-columns: 1fr;
  }

  .route-step {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .route-step .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .modal-actions .btn {
    flex: 1;
    min-width: 140px;
  }

  .toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .realtime-banner {
    right: 0.75rem;
    bottom: 0.75rem;
    width: calc(100vw - 1.5rem);
    grid-template-columns: 1fr;
  }

  .realtime-banner-actions {
    justify-content: stretch;
  }

  .realtime-banner-actions .btn {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .audit-error-stats { grid-template-columns: 1fr; }

  .sidebar nav {
    display: block;
    grid-template-columns: none;
  }

  .sidebar nav a { flex: none; }
  .sidebar-footer { grid-template-columns: 1fr; }
  .user-meta-row { align-items: flex-start; }

  .login-page { padding: 1rem; }
  .login-showcase,
  .login-card { border-radius: 24px; }

  .metric-bar { grid-template-columns: 1fr; }
  .metric-bar .bar-label,
  .metric-bar .bar-value { text-align: left; }

  .page-header > div {
    width: 100%;
    justify-content: flex-start;
  }
}
