@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f4f8ff;
  --bg-2: #e8f1ff;
  --accent: #2b7bff;
  --accent-2: #6fb0ff;
  --text: #10213b;
  --muted: #4a6285;
  --danger: #e5485d;
  --card: #ffffff;
  --stroke: rgba(16, 33, 59, 0.08);
  --shadow: 0 18px 45px rgba(23, 56, 97, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0%, #eef4ff 35%, #dfeaff 100%);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

select {
  min-width: 170px;
  padding: 10px 40px 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background-color: #f2f6ff;
  color: var(--text);
  font: inherit;
}

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #f8fbff 0%, #e6f0ff 100%);
  border-right: 1px solid var(--stroke);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 123, 255, 0.45) rgba(16, 33, 59, 0.08);
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(16, 33, 59, 0.08);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(43, 123, 255, 0.85), rgba(43, 123, 255, 0.55));
  border-radius: 999px;
  border: 2px solid rgba(248, 251, 255, 0.95);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(43, 123, 255, 0.95), rgba(43, 123, 255, 0.7));
}

.brand { font-weight: 700; letter-spacing: 0.04em; font-size: 20px; margin-bottom: 6px; }
.brand__logo { font-size: 18px; }
.brand__sub { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }

.profile { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--stroke); }
.profile__avatar { width: 38px; height: 38px; border-radius: 12px; background: var(--bg-2); color: var(--accent); display: grid; place-items: center; }
.profile__name { font-weight: 600; }
.profile__role { font-size: 12px; color: var(--muted); }

.nav { display: grid; gap: 6px; font-weight: 500; }
.nav a {
  padding: 9px 12px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.nav__label { flex: 1; }
.nav__count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: linear-gradient(135deg, #e5485d 0%, #ff7c8b 100%); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.nav__count.is-hidden { display: none; }
.nav a.active, .nav a:hover { color: var(--text); border-color: var(--stroke); background: rgba(43, 123, 255, 0.12); }

.nav-logout { margin-top: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(229, 72, 93, 0.25); color: #d1364b; font-weight: 600; gap: 8px; }
.content { padding: 28px; background: var(--bg); min-width: 0; }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  padding: 18px 22px;
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--stroke);
}

.hero h1 { margin: 0; font-size: 28px; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.hero__title { display: flex; align-items: center; gap: 14px; }
.hero__actions { display: flex; align-items: center; gap: 12px; }

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(43, 123, 255, 0.12);
  border-radius: 999px;
  font-size: 13px;
}

.card { background: var(--card); border: 1px solid var(--stroke); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); }
.muted { color: var(--muted); font-size: 13px; }
.btn { padding: 10px 14px; border-radius: 12px; border: none; background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn-outline { border: 1px solid rgba(43, 123, 255, 0.25); background: transparent; color: var(--text); }
.btn-primary { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; }
.btn:disabled { opacity: 0.72; cursor: wait; filter: saturate(0.8); }

.table { width: 100%; border-collapse: collapse; margin-top: 22px; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--stroke); }
.table th { color: var(--muted); font-weight: 500; }
.table-wrap, .card .table, .caja-cart { -webkit-overflow-scrolling: touch; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.is-open {
  display: flex;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 19, 39, 0.4);
}

.modal__content {
  position: relative;
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  z-index: 1;
  display: grid;
  gap: 12px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-collapsed .app-shell {
  grid-template-columns: 72px 1fr;
}

.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 20px 10px;
}

.sidebar-collapsed .brand__sub,
.sidebar-collapsed .profile,
.sidebar-collapsed .nav__label,
.sidebar-collapsed .nav__count,
.sidebar-collapsed .nav a span {
  display: none;
}

.sidebar-collapsed .brand__logo {
  text-align: center;
  font-size: 0;
}

.sidebar-collapsed .brand__logo::before {
  content: 'SP';
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.sidebar-collapsed .nav {
  gap: 8px;
}

.sidebar-collapsed .nav a {
  justify-content: center;
  padding: 10px 0;
}

.sidebar-collapsed .nav a i {
  font-size: 16px;
}

.sidebar-collapsed .nav-logout {
  padding: 10px 0;
  justify-content: center;
  font-size: 0;
  gap: 0;
}

.sidebar-collapsed .nav-logout i {
  font-size: 16px;
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 310px);
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transform: translateX(-108%);
    transition: transform .22s ease;
    z-index: 70;
    visibility: hidden;
    pointer-events: none;
  }
  body.sidebar-open .sidebar { transform: translateX(0); visibility: visible; pointer-events: auto; }
  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(9, 19, 39, 0.36);
    z-index: 65;
  }
  .content { width: 100%; min-width: 0; padding: 16px; }
  .hero,
  .hero__title,
  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero {
    padding: 16px;
    margin-bottom: 18px;
  }
  .hero h1 { font-size: 24px; }
  .table-wrap { width: 100%; overflow-x: auto; overflow-y: hidden; }
  .table { min-width: 640px; }
}

@media (max-width: 600px) {
  .content { padding: 12px; }
  .card { border-radius: 16px; padding: 14px; }
  .hero { border-radius: 16px; padding: 14px; }
  .hero h1 { font-size: 21px; }
  .hero p { font-size: 12px; }
  .table { min-width: 600px; font-size: 13px; }
  .table th, .table td { padding: 10px 8px; }
  select { width: 100%; min-width: 0; }
}
