/* Layout — shell, sidebar, topbar */

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-sidebar);
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-primary-dark);
  color: #fff;
  transition: width var(--transition), transform var(--transition);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  min-height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar__brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__brand-name {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  line-height: var(--lh-tight);
}

.sidebar__brand-region {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-1);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--fs-sm);
  transition: background var(--transition), color var(--transition);
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar__link.is-active {
  background: rgba(162, 59, 59, 0.35);
  color: #fff;
}

.sidebar__link img,
.sidebar__link svg,
.sidebar__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
  filter: brightness(0) invert(1);
}

.sidebar__label {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar__footer {
  padding: var(--space-2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.sidebar__user--btn {
  width: 100%;
  text-align: left;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 4px;
  transition: background var(--transition);
}

.sidebar__user--btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar__user-meta {
  overflow: hidden;
}

.sidebar__user-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.6);
}

.sidebar__logout {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-size: var(--fs-sm);
  transition: background var(--transition);
}

.sidebar__logout:hover {
  background: rgba(162, 59, 59, 0.4);
  color: #fff;
}

.sidebar__logout img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

/* Sidebar colapsado */
.app-shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

.app-shell.sidebar-collapsed .sidebar__brand-text,
.app-shell.sidebar-collapsed .sidebar__label,
.app-shell.sidebar-collapsed .sidebar__user-meta,
.app-shell.sidebar-collapsed .sidebar__logout span {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar__brand,
.app-shell.sidebar-collapsed .sidebar__link,
.app-shell.sidebar-collapsed .sidebar__logout {
  justify-content: center;
}

.app-shell.sidebar-collapsed .sidebar__user {
  justify-content: center;
}

/* Main area */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.app-shell.sidebar-collapsed .main-area {
  margin-left: var(--sidebar-collapsed);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: var(--space-2);
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.topbar__start {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  justify-self: start;
}

.topbar__menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  flex-shrink: 0;
}

.topbar__menu-btn:hover {
  background: var(--color-bg);
}

.topbar__menu-btn img {
  width: 22px;
  height: 22px;
}

.topbar__breadcrumb {
  min-width: 0;
}

.topbar__title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--color-primary);
  line-height: var(--lh-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: center;
  max-width: 100%;
}

.topbar__identity-seal {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(16, 27, 49, 0.12));
}

.topbar__identity-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.15;
  min-width: 0;
}

.topbar__identity-motto {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  white-space: nowrap;
}

.topbar__identity-region {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar__end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  justify-self: end;
  min-width: 0;
}

.topbar__search {
  position: relative;
  width: 240px;
}

.topbar__search .search-field,
.topbar__search-field {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: none;
  flex: none;
  height: 36px;
  background: var(--color-bg);
}

.topbar__search .search-field:focus-within {
  background: var(--color-surface);
}

.topbar__search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: var(--fs-sm);
}

.topbar__search .search-field .topbar__search-input {
  padding-left: 36px;
  padding-right: 36px;
}

.topbar__search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.topbar__search-icon,
.search-field__icon.topbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  z-index: 2;
  color: var(--color-text-muted);
  pointer-events: none;
  opacity: 0.7;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.topbar__icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.topbar__icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}

.topbar__icon-btn img {
  width: 20px;
  height: 20px;
}

.topbar__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
}

.topbar__notif-wrap {
  position: relative;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius);
  transition: background var(--transition);
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.topbar__user:hover {
  background: var(--color-bg);
}

.topbar__user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.topbar__user-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  flex: 1;
  padding: var(--space-3);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

.content--fade {
  
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 27, 49, 0.45);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
  pointer-events: none;
}

/* Login */

.login-body {
  background: var(--color-surface);
}

.login-split {
  display: grid;
  grid-template-columns: minmax(260px, 34%) 1fr;
  min-height: 100vh;
  width: 100%;
  background: var(--color-surface);
}

.login-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  color: #fff;
  overflow: hidden;
  min-height: 100vh;
  background: #1a1a1a;
}

.login-brand__media {
  position: absolute;
  inset: 0;
  background:
    url('../assets/img/login-brand.png') center / cover no-repeat;
}

.login-brand__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(16, 27, 49, 0.25) 0%, rgba(16, 27, 49, 0.35) 40%, rgba(16, 27, 49, 0.88) 100%);
}

.login-brand__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  gap: clamp(28px, 5vh, 56px);
  padding: clamp(28px, 4vw, 48px);
}

.login-brand__top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.login-brand__isotipo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.login-brand__name {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
}

.login-brand__region {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.72);
}

.login-brand__bottom {
  max-width: 420px;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: var(--space-2);
}

.login-brand__sello {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: var(--space-3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.login-brand__quote {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 12px;
  text-wrap: balance;
}

.login-brand__quote-meta {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.7);
}

.login-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(24px, 5vw, 64px);
  background:
    radial-gradient(1100px 560px at 92% -8%, rgba(28, 43, 74, 0.09), transparent 58%),
    radial-gradient(820px 480px at -8% 108%, rgba(162, 59, 59, 0.08), transparent 52%),
    radial-gradient(640px 420px at 48% 52%, rgba(176, 141, 87, 0.05), transparent 60%),
    linear-gradient(165deg, #f4f6f9 0%, #e9edf3 45%, #f2f4f7 100%);
  overflow: hidden;
}

.login-panel__ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.login-panel__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.6;
  will-change: transform;
}

.login-panel__orb--1 {
  width: min(420px, 48vw);
  height: min(420px, 48vw);
  top: -12%;
  right: -8%;
  background: radial-gradient(circle, rgba(28, 43, 74, 0.26) 0%, rgba(28, 43, 74, 0) 70%);
  animation: loginOrbDriftA 18s ease-in-out infinite alternate;
}

.login-panel__orb--2 {
  width: min(360px, 42vw);
  height: min(360px, 42vw);
  bottom: -10%;
  left: -6%;
  background: radial-gradient(circle, rgba(162, 59, 59, 0.2) 0%, rgba(162, 59, 59, 0) 70%);
  animation: loginOrbDriftB 22s ease-in-out infinite alternate;
}

.login-panel__orb--3 {
  width: min(280px, 34vw);
  height: min(280px, 34vw);
  top: 42%;
  left: 38%;
  background: radial-gradient(circle, rgba(176, 141, 87, 0.16) 0%, rgba(176, 141, 87, 0) 70%);
  animation: loginOrbDriftC 26s ease-in-out infinite alternate;
}

.login-panel__grid {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(28, 43, 74, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 43, 74, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 72% 62% at 50% 45%, #000 18%, transparent 78%);
  animation: loginGridPulse 12s ease-in-out infinite;
}

.login-panel__stripes {
  position: absolute;
  inset: -20%;
  opacity: 0.5;
  background: repeating-linear-gradient(
    -32deg,
    transparent 0,
    transparent 18px,
    rgba(28, 43, 74, 0.03) 18px,
    rgba(28, 43, 74, 0.03) 19px,
    transparent 19px,
    transparent 38px,
    rgba(162, 59, 59, 0.025) 38px,
    rgba(162, 59, 59, 0.025) 39px
  );
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 60% 40%, #000 10%, transparent 72%);
  mask-image: radial-gradient(ellipse 85% 75% at 60% 40%, #000 10%, transparent 72%);
}

.login-panel__rings {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(28, 43, 74, 0.1);
  box-shadow:
    inset 0 0 0 14px transparent,
    0 0 0 12px rgba(28, 43, 74, 0.04),
    0 0 0 28px rgba(162, 59, 59, 0.035);
}

.login-panel__rings--tl {
  width: min(340px, 46vw);
  height: min(340px, 46vw);
  top: -18%;
  left: -12%;
  border-color: rgba(28, 43, 74, 0.12);
  animation: loginRingPulse 16s ease-in-out infinite;
}

.login-panel__rings--br {
  width: min(420px, 52vw);
  height: min(420px, 52vw);
  bottom: -22%;
  right: -16%;
  border-color: rgba(162, 59, 59, 0.12);
  box-shadow:
    0 0 0 16px rgba(162, 59, 59, 0.04),
    0 0 0 36px rgba(28, 43, 74, 0.035),
    0 0 0 58px rgba(176, 141, 87, 0.03);
  animation: loginRingPulse 20s ease-in-out infinite reverse;
}

.login-panel__arc {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
}

.login-panel__arc--1 {
  width: min(520px, 70vw);
  height: min(520px, 70vw);
  top: 8%;
  right: -28%;
  border-top-color: rgba(28, 43, 74, 0.1);
  border-right-color: rgba(28, 43, 74, 0.06);
  transform: rotate(18deg);
}

.login-panel__arc--2 {
  width: min(380px, 55vw);
  height: min(380px, 55vw);
  bottom: 6%;
  left: -18%;
  border-bottom-color: rgba(162, 59, 59, 0.12);
  border-left-color: rgba(176, 141, 87, 0.08);
  transform: rotate(-12deg);
}

.login-panel__star {
  position: absolute;
  color: var(--color-primary);
  opacity: 0.07;
}

.login-panel__star--hero {
  width: min(280px, 38vw);
  height: min(280px, 38vw);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  color: var(--color-primary);
  opacity: 0.045;
}

.login-panel__star--a {
  width: 28px;
  height: 28px;
  top: 14%;
  right: 12%;
  color: var(--color-accent);
  opacity: 0.18;
  animation: loginStarFloat 9s ease-in-out infinite;
}

.login-panel__star--b {
  width: 18px;
  height: 18px;
  top: 28%;
  left: 10%;
  opacity: 0.12;
  animation: loginStarFloat 11s ease-in-out infinite 1.2s;
}

.login-panel__star--c {
  width: 22px;
  height: 22px;
  bottom: 18%;
  right: 18%;
  color: var(--color-gold);
  opacity: 0.2;
  animation: loginStarFloat 10s ease-in-out infinite 0.6s;
}

.login-panel__star--d {
  width: 14px;
  height: 14px;
  bottom: 32%;
  left: 16%;
  color: var(--color-accent);
  opacity: 0.14;
  animation: loginStarFloat 13s ease-in-out infinite 2s;
}

.login-panel__corner {
  position: absolute;
  width: 72px;
  height: 72px;
}

.login-panel__corner--tr {
  top: 28px;
  right: 28px;
  border-top: 2px solid rgba(28, 43, 74, 0.16);
  border-right: 2px solid rgba(162, 59, 59, 0.22);
}

.login-panel__corner--bl {
  bottom: 28px;
  left: 28px;
  border-bottom: 2px solid rgba(28, 43, 74, 0.16);
  border-left: 2px solid rgba(176, 141, 87, 0.28);
}

.login-panel__inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

@keyframes loginOrbDriftA {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-36px, 28px) scale(1.08); }
}

@keyframes loginOrbDriftB {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, -24px) scale(1.1); }
}

@keyframes loginOrbDriftC {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-20px, -32px) scale(0.94); }
}

@keyframes loginGridPulse {
  0%, 100% { opacity: 0.32; }
  50% { opacity: 0.48; }
}

@keyframes loginRingPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

@keyframes loginStarFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}

@media (prefers-reduced-motion: reduce) {
  .login-panel__orb--1,
  .login-panel__orb--2,
  .login-panel__orb--3,
  .login-panel__grid,
  .login-panel__rings,
  .login-panel__star--a,
  .login-panel__star--b,
  .login-panel__star--c,
  .login-panel__star--d {
    animation: none;
  }
}

.login-panel__header {
  margin-bottom: var(--space-4);
}

.login-panel__wordmark {
  max-width: 200px;
  margin-bottom: var(--space-3);
}

.login-panel__title {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3vw, 36px);
  color: var(--color-primary);
  line-height: 1.15;
  margin: 0 0 10px;
}

.login-panel__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field.has-error .login-field__input {
  border-color: var(--color-danger);
}

.login-field.has-error .form-error {
  display: block;
}

.login-field__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.login-field__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text);
}

.login-field__input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: var(--fs-sm);
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.login-field__input::placeholder {
  color: #9aa1ad;
}

.login-field__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(28, 43, 74, 0.12);
}

.login-field__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B6270' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.login-form__remember {
  margin-top: 4px;
}

.login-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.login-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.login-switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-border);
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease-out);
}

.login-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform var(--duration-fast) var(--ease-out);
}

.login-switch input:checked + .login-switch__track {
  background: var(--color-primary);
}

.login-switch input:checked + .login-switch__track::after {
  transform: translateX(18px);
}

.login-switch input:focus-visible + .login-switch__track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.login-switch__text {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.login-form__submit {
  height: 48px;
  margin-top: 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.login-panel__footnote {
  margin-top: var(--space-3);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.login-panel__footnote strong {
  color: var(--color-primary);
  font-weight: 600;
}
