:root {
  color-scheme: light;
  --app-bottom-safe: env(safe-area-inset-bottom, 0px);
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
}

body,
button,
input,
select,
textarea {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.safe-bottom {
  padding-bottom: calc(1rem + var(--app-bottom-safe));
}

.tap-target {
  min-height: 44px;
  min-width: 44px;
}

.glass-panel {
  backdrop-filter: blur(16px);
}

.brand-surface {
  background: #f8fafc;
}

/* Shared form controls --------------------------------------------------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  border: 1px solid #dbe2ea;
  border-radius: 0.875rem;
  background-color: #fff;
  padding: 0.72rem 0.85rem;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.025);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):hover,
select:hover,
textarea:hover {
  border-color: #b9c3d0;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
select:focus,
textarea:focus {
  border-color: #dd8900;
  outline: none;
  box-shadow: 0 0 0 4px rgba(221, 137, 0, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #dd8900;
}

/* Administration shell ------------------------------------------------- */
.admin-app {
  background:
    radial-gradient(circle at 85% -10%, rgba(251, 146, 60, 0.09), transparent 32rem),
    linear-gradient(145deg, #f8fafc 0%, #f1f5f9 52%, #f8fafc 100%);
}

.admin-sidebar {
  color: #e2e8f0;
  background:
    linear-gradient(155deg, rgba(30, 41, 59, 0.2), rgba(15, 23, 42, 0.8)),
    #07101f;
  box-shadow: 20px 0 50px rgba(15, 23, 42, 0.14);
  transform: translateX(-100%);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

.admin-sidebar-scroll {
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
  scrollbar-width: thin;
}

.admin-nav {
  display: grid;
  gap: 0.3rem;
}

.admin-nav-label {
  padding: 0.35rem 0.8rem 0.45rem;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.admin-nav-link {
  position: relative;
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.8rem;
  overflow: hidden;
  border-radius: 0.85rem;
  padding: 0.68rem 0.8rem;
  color: #aebccc;
  font-size: 0.875rem;
  font-weight: 600;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.admin-nav-link::before {
  position: absolute;
  inset-block: 0.6rem;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: #fb923c;
  content: "";
  opacity: 0;
  transform: scaleY(0.35);
  transition: opacity 180ms ease, transform 180ms ease;
}

.admin-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.075);
  transform: translateX(2px);
}

.admin-nav-link.is-active {
  color: #fff;
  background: linear-gradient(100deg, rgba(249, 115, 22, 0.2), rgba(255, 255, 255, 0.075));
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.12);
}

.admin-nav-link.is-active::before {
  opacity: 1;
  transform: scaleY(1);
}

.admin-nav-link svg {
  flex: 0 0 auto;
  transition: transform 180ms ease;
}

.admin-nav-link:hover svg {
  transform: scale(1.08);
}

.admin-nav-link-danger:hover,
.admin-nav-link-danger.is-active {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.13);
}

.admin-nav-link-danger::before {
  background: #ef4444;
}

.admin-topbar {
  backdrop-filter: blur(18px) saturate(150%);
}

.admin-header-action {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.8rem;
  padding: 0.55rem 0.8rem;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.admin-header-action:hover {
  color: #0f172a;
  background: #f1f5f9;
  transform: translateY(-1px);
}

.admin-content {
  animation: admin-content-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.admin-content .rounded-2xl.bg-white,
.admin-content .rounded-3xl.bg-white {
  border-color: rgba(226, 232, 240, 0.7);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.055);
}

.admin-content a,
.admin-content button {
  transition-duration: 180ms;
}

.admin-primary-button,
.admin-secondary-button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.8rem;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 750;
  line-height: 1.15;
}

.admin-primary-button {
  background: linear-gradient(135deg, #f97316, #d97706);
  color: #fff;
  box-shadow: 0 10px 24px rgba(249, 115, 22, 0.2);
}

.admin-primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(249, 115, 22, 0.3);
}

.admin-secondary-button {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
}

.admin-secondary-button:hover {
  border-color: #fdba74;
  color: #c2410c;
}

/* Evita botones altos con texto descentrado en encabezados y barras de acción. */
.admin-content a[class*="px-"],
.admin-content button[class*="px-"] {
  line-height: 1.15;
}

.admin-welcome-panel,
.profile-hero,
.profile-form-header {
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.45), rgba(2, 6, 23, 0.25)),
    linear-gradient(130deg, #111c2d, #020617 70%);
}

.admin-hero-button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.7rem 1rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 750;
  backdrop-filter: blur(10px);
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.admin-hero-button:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.admin-hero-button-primary {
  border-color: rgba(251, 146, 60, 0.45);
  background: linear-gradient(135deg, #f97316, #dd8900);
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.23);
}

.subscription-card,
.metric-card {
  border: 1px solid rgba(226, 232, 240, 0.72);
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.055);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.subscription-card:hover,
.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.09);
}

.metric-card-glow {
  position: absolute;
  top: -2rem;
  right: -2rem;
  width: 7rem;
  height: 7rem;
  border-radius: 999px;
  background: rgba(251, 146, 60, 0.1);
  filter: blur(1.5rem);
  transition: transform 300ms ease, opacity 300ms ease;
}

.metric-card:hover .metric-card-glow {
  opacity: 1.4;
  transform: scale(1.3);
}

.metric-card-icon {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.9rem;
  background: #fff7ed;
  color: #c2410c;
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.12);
}

@keyframes admin-content-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Resident navigation and profile -------------------------------------- */
.resident-app,
.profile-page {
  background:
    radial-gradient(circle at 90% -5%, color-mix(in srgb, var(--tenant-primary, #dd8900) 10%, transparent), transparent 22rem),
    linear-gradient(155deg, #f8fafc, #f1f5f9 65%, #fff7ed);
}

.resident-bottom-nav {
  border-top: 1px solid rgba(226, 232, 240, 0.82);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 -12px 35px rgba(15, 23, 42, 0.08);
}

.resident-bottom-link {
  display: flex;
  min-height: 3.5rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  border-radius: 1rem;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 700;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.resident-bottom-link:hover {
  color: var(--tenant-primary, #c2410c);
  background: #f8fafc;
  transform: translateY(-1px);
}

.resident-bottom-home {
  color: var(--tenant-primary, #c2410c);
}

.resident-home-icon {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--tenant-primary, #dd8900) 12%, white);
}

.profile-action {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  border-radius: 1rem;
  background: #f8fafc;
  padding: 0.8rem;
  color: #0f172a;
  transition: background-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.profile-action:hover {
  background: #fff7ed;
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.16);
  transform: translateY(-1px);
}

.profile-action > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.profile-action strong {
  overflow: hidden;
  font-size: 0.83rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-action small {
  overflow: hidden;
  margin-top: 0.1rem;
  color: #64748b;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-action-icon {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.8rem;
  background: #fff;
  color: #c2410c;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.system-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.9rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
}

.system-credit a {
  color: #475569;
  font-weight: 800;
  transition: color 180ms ease;
}

.system-credit a:hover {
  color: #dd8900;
}

.residev-credential-popup {
  border-radius: 1.75rem !important;
  overflow: hidden;
}

.residev-request-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.residev-request-loader[hidden] {
  display: none;
}

.residev-request-loader-card {
  display: flex;
  min-width: min(20rem, 90vw);
  align-items: center;
  gap: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 1.5rem;
  background: linear-gradient(135deg, #111827, #020617);
  padding: 1.1rem 1.25rem;
  color: #fff;
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.45);
}

.residev-request-loader-card strong,
.residev-request-loader-card small {
  display: block;
}

.residev-request-loader-card small {
  margin-top: 0.15rem;
  color: #cbd5e1;
  font-size: 0.75rem;
}

.residev-request-loader-mark {
  display: grid;
  width: 2.9rem;
  height: 2.9rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, #f97316, #f59e0b);
  box-shadow: 0 10px 28px rgba(249, 115, 22, 0.35);
}

.residev-request-loader-mark span {
  width: 1.45rem;
  height: 1.45rem;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 999px;
  animation: residev-loader-spin 700ms linear infinite;
}

.residev-loading,
.residev-loading body {
  overflow: hidden;
}

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

.guard-bottom-link {
  display: flex;
  min-height: 3.7rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-radius: 1rem;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 750;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.guard-bottom-link:active {
  transform: scale(0.96);
}

.guard-bottom-link.is-active {
  background: #fff7ed;
  color: #c2410c;
}

@media (min-width: 1024px) {
  .admin-sidebar {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
